2 * Copyright (C) 2004 John Ellis
3 * Copyright (C) 2008 - 2016 The Geeqie Team
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 #include "layout_util.h"
25 #include "advanced_exif.h"
28 #include "cache_maint.h"
30 #include "collect-dlg.h"
32 #include "color-man.h"
36 #include "history_list.h"
37 #include "image-overlay.h"
38 #include "histogram.h"
40 #include "layout_image.h"
41 #include "logwindow.h"
44 #include "pixbuf_util.h"
45 #include "preferences.h"
48 #include "ui_fileops.h"
51 #include "ui_tabcomp.h"
54 #include "view_file.h"
57 #include "desktop_file.h"
59 #include <gdk/gdkkeysyms.h> /* for keyboard values */
60 #include "keymap_template.c"
62 #define MENU_EDIT_ACTION_OFFSET 16
63 #define FILE_COLUMN_POINTER 0
65 static gboolean layout_bar_enabled(LayoutWindow *lw);
66 static gboolean layout_bar_sort_enabled(LayoutWindow *lw);
67 static void layout_bars_hide_toggle(LayoutWindow *lw);
68 static void layout_util_sync_views(LayoutWindow *lw);
71 *-----------------------------------------------------------------------------
73 *-----------------------------------------------------------------------------
76 static guint tree_key_overrides[] = {
77 GDK_KEY_Page_Up, GDK_KEY_KP_Page_Up,
78 GDK_KEY_Page_Down, GDK_KEY_KP_Page_Down,
79 GDK_KEY_Home, GDK_KEY_KP_Home,
80 GDK_KEY_End, GDK_KEY_KP_End
83 static gboolean layout_key_match(guint keyval)
87 for (i = 0; i < sizeof(tree_key_overrides) / sizeof(guint); i++)
89 if (keyval == tree_key_overrides[i]) return TRUE;
95 gboolean layout_key_press_cb(GtkWidget *widget, GdkEventKey *event, gpointer data)
97 LayoutWindow *lw = data;
99 gboolean stop_signal = FALSE;
103 if (lw->path_entry && gtk_widget_has_focus(lw->path_entry))
105 if (event->keyval == GDK_KEY_Escape && lw->dir_fd)
107 gtk_entry_set_text(GTK_ENTRY(lw->path_entry), lw->dir_fd->path);
110 /* the gtkaccelgroup of the window is stealing presses before they get to the entry (and more),
111 * so when the some widgets have focus, give them priority (HACK)
113 if (gtk_widget_event(lw->path_entry, (GdkEvent *)event))
118 if (lw->vd && lw->options.dir_view_type == DIRVIEW_TREE && gtk_widget_has_focus(lw->vd->view) &&
119 !layout_key_match(event->keyval) &&
120 gtk_widget_event(lw->vd->view, (GdkEvent *)event))
125 bar_event(lw->bar, (GdkEvent *)event))
130 focused = gtk_container_get_focus_child(GTK_CONTAINER(lw->image->widget));
132 ((focused && gtk_widget_has_focus(focused)) || (lw->tools && widget == lw->window) || lw->full_screen) )
135 switch (event->keyval)
137 case GDK_KEY_Left: case GDK_KEY_KP_Left:
140 case GDK_KEY_Right: case GDK_KEY_KP_Right:
143 case GDK_KEY_Up: case GDK_KEY_KP_Up:
146 case GDK_KEY_Down: case GDK_KEY_KP_Down:
155 !(event->state & GDK_CONTROL_MASK))
158 switch (event->keyval)
161 layout_image_menu_popup(lw);
172 keyboard_scroll_calc(&x, &y, event);
173 layout_image_scroll(lw, x, y, (event->state & GDK_SHIFT_MASK));
179 void layout_keyboard_init(LayoutWindow *lw, GtkWidget *window)
181 g_signal_connect(G_OBJECT(window), "key_press_event",
182 G_CALLBACK(layout_key_press_cb), lw);
186 *-----------------------------------------------------------------------------
188 *-----------------------------------------------------------------------------
192 static GtkWidget *layout_window(LayoutWindow *lw)
194 return lw->full_screen ? lw->full_screen->window : lw->window;
197 static void layout_exit_fullscreen(LayoutWindow *lw)
199 if (!lw->full_screen) return;
200 layout_image_full_screen_stop(lw);
203 static void layout_menu_new_window_cb(GtkAction *action, gpointer data)
205 LayoutWindow *lw = data;
208 gboolean tmp = options->save_window_positions;
210 if (!options->use_saved_window_positions_for_new_windows)
211 options->save_window_positions = FALSE; /* let the windowmanager decide for the first time */
213 layout_exit_fullscreen(lw);
215 layout_sync_options_with_current_state(lw);
216 lop = lw->options; /* we can copy it directly, no strings are modified */
218 lop.id = NULL; /* get a new id */
219 nw = layout_new(NULL, &lop);
220 layout_sort_set(nw, options->file_sort.method, options->file_sort.ascending);
221 layout_set_fd(nw, lw->dir_fd);
222 options->save_window_positions = tmp;
225 static void layout_menu_new_cb(GtkAction *action, gpointer data)
227 LayoutWindow *lw = data;
229 layout_exit_fullscreen(lw);
230 collection_window_new(NULL);
233 static void layout_menu_open_cb(GtkAction *action, gpointer data)
235 LayoutWindow *lw = data;
237 layout_exit_fullscreen(lw);
238 collection_dialog_load(NULL);
241 static void layout_menu_search_cb(GtkAction *action, gpointer data)
243 LayoutWindow *lw = data;
245 layout_exit_fullscreen(lw);
246 search_new(lw->dir_fd, layout_image_get_fd(lw));
249 static void layout_menu_dupes_cb(GtkAction *action, gpointer data)
251 LayoutWindow *lw = data;
253 layout_exit_fullscreen(lw);
257 static void layout_menu_pan_cb(GtkAction *action, gpointer data)
259 LayoutWindow *lw = data;
261 layout_exit_fullscreen(lw);
262 pan_window_new(lw->dir_fd);
265 static void layout_menu_print_cb(GtkAction *action, gpointer data)
267 LayoutWindow *lw = data;
269 print_window_new(layout_image_get_fd(lw), layout_selection_list(lw), layout_list(lw), layout_window(lw));
272 static void layout_menu_dir_cb(GtkAction *action, gpointer data)
274 LayoutWindow *lw = data;
276 if (lw->vd) vd_new_folder(lw->vd, lw->dir_fd);
279 static void layout_menu_copy_cb(GtkAction *action, gpointer data)
281 LayoutWindow *lw = data;
283 file_util_copy(NULL, layout_selection_list(lw), NULL, layout_window(lw));
286 static void layout_menu_copy_path_cb(GtkAction *action, gpointer data)
288 LayoutWindow *lw = data;
290 file_util_copy_path_list_to_clipboard(layout_selection_list(lw));
293 static void layout_menu_move_cb(GtkAction *action, gpointer data)
295 LayoutWindow *lw = data;
297 file_util_move(NULL, layout_selection_list(lw), NULL, layout_window(lw));
300 static void layout_menu_rename_cb(GtkAction *action, gpointer data)
302 LayoutWindow *lw = data;
304 file_util_rename(NULL, layout_selection_list(lw), layout_window(lw));
307 static void layout_menu_delete_cb(GtkAction *action, gpointer data)
309 LayoutWindow *lw = data;
311 file_util_delete(NULL, layout_selection_list(lw), layout_window(lw));
314 static void layout_menu_delete_key_cb(GtkAction *action, gpointer data)
316 LayoutWindow *lw = data;
318 if (options->file_ops.enable_delete_key)
320 file_util_delete(NULL, layout_selection_list(lw), layout_window(lw));
324 static void layout_menu_disable_grouping_cb(GtkAction *action, gpointer data)
326 LayoutWindow *lw = data;
328 file_data_disable_grouping_list(layout_selection_list(lw), TRUE);
331 static void layout_menu_enable_grouping_cb(GtkAction *action, gpointer data)
333 LayoutWindow *lw = data;
335 file_data_disable_grouping_list(layout_selection_list(lw), FALSE);
338 static void layout_menu_close_cb(GtkAction *action, gpointer data)
340 LayoutWindow *lw = data;
342 layout_exit_fullscreen(lw);
346 static void layout_menu_exit_cb(GtkAction *action, gpointer data)
351 static void layout_menu_alter_90_cb(GtkAction *action, gpointer data)
353 LayoutWindow *lw = data;
355 layout_image_alter_orientation(lw, ALTER_ROTATE_90);
358 static void layout_menu_rating_0_cb(GtkAction *action, gpointer data)
360 LayoutWindow *lw = data;
362 layout_image_rating(lw, "0");
365 static void layout_menu_rating_1_cb(GtkAction *action, gpointer data)
367 LayoutWindow *lw = data;
369 layout_image_rating(lw, "1");
372 static void layout_menu_rating_2_cb(GtkAction *action, gpointer data)
374 LayoutWindow *lw = data;
376 layout_image_rating(lw, "2");
379 static void layout_menu_rating_3_cb(GtkAction *action, gpointer data)
381 LayoutWindow *lw = data;
383 layout_image_rating(lw, "3");
386 static void layout_menu_rating_4_cb(GtkAction *action, gpointer data)
388 LayoutWindow *lw = data;
390 layout_image_rating(lw, "4");
393 static void layout_menu_rating_5_cb(GtkAction *action, gpointer data)
395 LayoutWindow *lw = data;
397 layout_image_rating(lw, "5");
400 static void layout_menu_rating_m1_cb(GtkAction *action, gpointer data)
402 LayoutWindow *lw = data;
404 layout_image_rating(lw, "-1");
407 static void layout_menu_alter_90cc_cb(GtkAction *action, gpointer data)
409 LayoutWindow *lw = data;
411 layout_image_alter_orientation(lw, ALTER_ROTATE_90_CC);
414 static void layout_menu_alter_180_cb(GtkAction *action, gpointer data)
416 LayoutWindow *lw = data;
418 layout_image_alter_orientation(lw, ALTER_ROTATE_180);
421 static void layout_menu_alter_mirror_cb(GtkAction *action, gpointer data)
423 LayoutWindow *lw = data;
425 layout_image_alter_orientation(lw, ALTER_MIRROR);
428 static void layout_menu_alter_flip_cb(GtkAction *action, gpointer data)
430 LayoutWindow *lw = data;
432 layout_image_alter_orientation(lw, ALTER_FLIP);
435 static void layout_menu_alter_desaturate_cb(GtkToggleAction *action, gpointer data)
437 LayoutWindow *lw = data;
439 layout_image_set_desaturate(lw, gtk_toggle_action_get_active(action));
442 static void layout_menu_alter_none_cb(GtkAction *action, gpointer data)
444 LayoutWindow *lw = data;
446 layout_image_alter_orientation(lw, ALTER_NONE);
449 static void layout_menu_exif_rotate_cb(GtkToggleAction *action, gpointer data)
451 LayoutWindow *lw = data;
453 options->image.exif_rotate_enable = gtk_toggle_action_get_active(action);
454 layout_image_reset_orientation(lw);
457 static void layout_menu_write_rotate(GtkToggleAction *action, gpointer data, gboolean keep_date)
459 LayoutWindow *lw = data;
462 GtkTreeSelection *selection;
473 if (!layout_valid(&lw)) return;
475 if (!lw || !lw->vf) return;
477 if (lw->vf->type == FILEVIEW_ICON)
479 if (!VFICON(lw->vf)->selection) return;
480 work = VFICON(lw->vf)->selection;
484 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(lw->vf->listview));
485 work = gtk_tree_selection_get_selected_rows(selection, &store);
490 if (lw->vf->type == FILEVIEW_ICON)
499 gtk_tree_model_get_iter(store, &iter, tpath);
500 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &fd_n, -1);
504 rotation = g_strdup_printf("%d", fd_n->user_orientation);
505 command = g_strconcat(GQ_BIN_DIR, "/geeqie-rotate -r ", rotation,
506 keep_date ? " -t " : " ", fd_n->path, NULL);
508 run_result = WEXITSTATUS(runcmd(command));
511 fd_n->user_orientation = 0;
515 message = g_string_new("");
516 message = g_string_append(message, _("Operation failed:\n"));
519 message = g_string_append(message, _("Cannot create tmp file"));
522 message = g_string_append(message, _("File: "));
523 message = g_string_append(message, fd_n->name);
526 gd = generic_dialog_new(_("Image orientation"),
527 "Image orientation", NULL, TRUE, NULL, NULL);
528 generic_dialog_add_message(gd, GTK_STOCK_DIALOG_ERROR,
529 "Image orientation", message->str);
530 generic_dialog_add_button(gd, GTK_STOCK_OK, NULL, NULL, TRUE);
532 gtk_widget_show(gd->dialog);
534 g_string_free(message, TRUE);
542 static void layout_menu_write_rotate_keep_date_cb(GtkToggleAction *action, gpointer data)
544 layout_menu_write_rotate(action, data, TRUE);
547 static void layout_menu_write_rotate_cb(GtkToggleAction *action, gpointer data)
549 layout_menu_write_rotate(action, data, FALSE);
552 static void layout_menu_config_cb(GtkAction *action, gpointer data)
554 LayoutWindow *lw = data;
556 layout_exit_fullscreen(lw);
557 show_config_window();
560 static void layout_menu_editors_cb(GtkAction *action, gpointer data)
562 LayoutWindow *lw = data;
564 layout_exit_fullscreen(lw);
565 show_editor_list_window();
568 static void layout_menu_layout_config_cb(GtkAction *action, gpointer data)
570 LayoutWindow *lw = data;
572 layout_exit_fullscreen(lw);
573 layout_show_config_window(lw);
576 static void layout_menu_remove_thumb_cb(GtkAction *action, gpointer data)
578 LayoutWindow *lw = data;
580 layout_exit_fullscreen(lw);
581 cache_manager_show();
584 static void layout_menu_wallpaper_cb(GtkAction *action, gpointer data)
586 LayoutWindow *lw = data;
588 layout_image_to_root(lw);
591 /* single window zoom */
592 static void layout_menu_zoom_in_cb(GtkAction *action, gpointer data)
594 LayoutWindow *lw = data;
596 layout_image_zoom_adjust(lw, get_zoom_increment(), FALSE);
599 static void layout_menu_zoom_out_cb(GtkAction *action, gpointer data)
601 LayoutWindow *lw = data;
603 layout_image_zoom_adjust(lw, -get_zoom_increment(), FALSE);
606 static void layout_menu_zoom_1_1_cb(GtkAction *action, gpointer data)
608 LayoutWindow *lw = data;
610 layout_image_zoom_set(lw, 1.0, FALSE);
613 static void layout_menu_zoom_fit_cb(GtkAction *action, gpointer data)
615 LayoutWindow *lw = data;
617 layout_image_zoom_set(lw, 0.0, FALSE);
620 static void layout_menu_zoom_fit_hor_cb(GtkAction *action, gpointer data)
622 LayoutWindow *lw = data;
624 layout_image_zoom_set_fill_geometry(lw, FALSE, FALSE);
627 static void layout_menu_zoom_fit_vert_cb(GtkAction *action, gpointer data)
629 LayoutWindow *lw = data;
631 layout_image_zoom_set_fill_geometry(lw, TRUE, FALSE);
634 static void layout_menu_zoom_2_1_cb(GtkAction *action, gpointer data)
636 LayoutWindow *lw = data;
638 layout_image_zoom_set(lw, 2.0, FALSE);
641 static void layout_menu_zoom_3_1_cb(GtkAction *action, gpointer data)
643 LayoutWindow *lw = data;
645 layout_image_zoom_set(lw, 3.0, FALSE);
647 static void layout_menu_zoom_4_1_cb(GtkAction *action, gpointer data)
649 LayoutWindow *lw = data;
651 layout_image_zoom_set(lw, 4.0, FALSE);
654 static void layout_menu_zoom_1_2_cb(GtkAction *action, gpointer data)
656 LayoutWindow *lw = data;
658 layout_image_zoom_set(lw, -2.0, FALSE);
661 static void layout_menu_zoom_1_3_cb(GtkAction *action, gpointer data)
663 LayoutWindow *lw = data;
665 layout_image_zoom_set(lw, -3.0, FALSE);
668 static void layout_menu_zoom_1_4_cb(GtkAction *action, gpointer data)
670 LayoutWindow *lw = data;
672 layout_image_zoom_set(lw, -4.0, FALSE);
676 static void layout_menu_connect_zoom_in_cb(GtkAction *action, gpointer data)
678 LayoutWindow *lw = data;
680 layout_image_zoom_adjust(lw, get_zoom_increment(), TRUE);
683 static void layout_menu_connect_zoom_out_cb(GtkAction *action, gpointer data)
685 LayoutWindow *lw = data;
687 layout_image_zoom_adjust(lw, -get_zoom_increment(), TRUE);
690 static void layout_menu_connect_zoom_1_1_cb(GtkAction *action, gpointer data)
692 LayoutWindow *lw = data;
694 layout_image_zoom_set(lw, 1.0, TRUE);
697 static void layout_menu_connect_zoom_fit_cb(GtkAction *action, gpointer data)
699 LayoutWindow *lw = data;
701 layout_image_zoom_set(lw, 0.0, TRUE);
704 static void layout_menu_connect_zoom_fit_hor_cb(GtkAction *action, gpointer data)
706 LayoutWindow *lw = data;
708 layout_image_zoom_set_fill_geometry(lw, FALSE, TRUE);
711 static void layout_menu_connect_zoom_fit_vert_cb(GtkAction *action, gpointer data)
713 LayoutWindow *lw = data;
715 layout_image_zoom_set_fill_geometry(lw, TRUE, TRUE);
718 static void layout_menu_connect_zoom_2_1_cb(GtkAction *action, gpointer data)
720 LayoutWindow *lw = data;
722 layout_image_zoom_set(lw, 2.0, TRUE);
725 static void layout_menu_connect_zoom_3_1_cb(GtkAction *action, gpointer data)
727 LayoutWindow *lw = data;
729 layout_image_zoom_set(lw, 3.0, TRUE);
731 static void layout_menu_connect_zoom_4_1_cb(GtkAction *action, gpointer data)
733 LayoutWindow *lw = data;
735 layout_image_zoom_set(lw, 4.0, TRUE);
738 static void layout_menu_connect_zoom_1_2_cb(GtkAction *action, gpointer data)
740 LayoutWindow *lw = data;
742 layout_image_zoom_set(lw, -2.0, TRUE);
745 static void layout_menu_connect_zoom_1_3_cb(GtkAction *action, gpointer data)
747 LayoutWindow *lw = data;
749 layout_image_zoom_set(lw, -3.0, TRUE);
752 static void layout_menu_connect_zoom_1_4_cb(GtkAction *action, gpointer data)
754 LayoutWindow *lw = data;
756 layout_image_zoom_set(lw, -4.0, TRUE);
760 static void layout_menu_split_cb(GtkRadioAction *action, GtkRadioAction *current, gpointer data)
762 LayoutWindow *lw = data;
765 layout_exit_fullscreen(lw);
766 mode = gtk_radio_action_get_current_value(action);
767 layout_split_change(lw, mode);
771 static void layout_menu_thumb_cb(GtkToggleAction *action, gpointer data)
773 LayoutWindow *lw = data;
775 layout_thumb_set(lw, gtk_toggle_action_get_active(action));
779 static void layout_menu_list_cb(GtkRadioAction *action, GtkRadioAction *current, gpointer data)
781 LayoutWindow *lw = data;
783 layout_exit_fullscreen(lw);
784 layout_views_set(lw, lw->options.dir_view_type, (FileViewType) gtk_radio_action_get_current_value(action));
787 static void layout_menu_view_dir_as_cb(GtkToggleAction *action, gpointer data)
789 LayoutWindow *lw = data;
791 layout_exit_fullscreen(lw);
793 if (gtk_toggle_action_get_active(action))
795 layout_views_set(lw, DIRVIEW_TREE, lw->options.file_view_type);
799 layout_views_set(lw, DIRVIEW_LIST, lw->options.file_view_type);
803 static void layout_menu_view_in_new_window_cb(GtkAction *action, gpointer data)
805 LayoutWindow *lw = data;
807 layout_exit_fullscreen(lw);
808 view_window_new(layout_image_get_fd(lw));
811 static void layout_menu_fullscreen_cb(GtkAction *action, gpointer data)
813 LayoutWindow *lw = data;
815 layout_image_full_screen_toggle(lw);
818 static void layout_menu_escape_cb(GtkAction *action, gpointer data)
820 LayoutWindow *lw = data;
822 layout_exit_fullscreen(lw);
825 static void layout_menu_overlay_toggle_cb(GtkAction *action, gpointer data)
827 LayoutWindow *lw = data;
829 image_osd_toggle(lw->image);
830 layout_util_sync_views(lw);
834 static void layout_menu_overlay_cb(GtkToggleAction *action, gpointer data)
836 LayoutWindow *lw = data;
838 if (gtk_toggle_action_get_active(action))
840 OsdShowFlags flags = image_osd_get(lw->image);
842 if ((flags | OSD_SHOW_INFO | OSD_SHOW_STATUS) != flags)
843 image_osd_set(lw->image, flags | OSD_SHOW_INFO | OSD_SHOW_STATUS);
847 GtkToggleAction *histogram_action = GTK_TOGGLE_ACTION(gtk_action_group_get_action(lw->action_group, "ImageHistogram"));
849 image_osd_set(lw->image, OSD_SHOW_NOTHING);
850 gtk_toggle_action_set_active(histogram_action, FALSE); /* this calls layout_menu_histogram_cb */
854 static void layout_menu_histogram_cb(GtkToggleAction *action, gpointer data)
856 LayoutWindow *lw = data;
858 if (gtk_toggle_action_get_active(action))
860 image_osd_set(lw->image, OSD_SHOW_INFO | OSD_SHOW_STATUS | OSD_SHOW_HISTOGRAM);
861 layout_util_sync_views(lw); /* show the overlay state, default channel and mode in the menu */
865 OsdShowFlags flags = image_osd_get(lw->image);
866 if (flags & OSD_SHOW_HISTOGRAM)
867 image_osd_set(lw->image, flags & ~OSD_SHOW_HISTOGRAM);
871 static void layout_menu_animate_cb(GtkToggleAction *action, gpointer data)
873 LayoutWindow *lw = data;
875 if (lw->options.animate == gtk_toggle_action_get_active(action)) return;
876 layout_image_animate_toggle(lw);
879 static void layout_menu_rectangular_selection_cb(GtkToggleAction *action, gpointer data)
881 LayoutWindow *lw = data;
883 options->collections.rectangular_selection = gtk_toggle_action_get_active(action);
886 static void layout_menu_histogram_toggle_channel_cb(GtkAction *action, gpointer data)
888 LayoutWindow *lw = data;
890 image_osd_histogram_toggle_channel(lw->image);
891 layout_util_sync_views(lw);
894 static void layout_menu_histogram_toggle_mode_cb(GtkAction *action, gpointer data)
896 LayoutWindow *lw = data;
898 image_osd_histogram_toggle_mode(lw->image);
899 layout_util_sync_views(lw);
902 static void layout_menu_histogram_channel_cb(GtkRadioAction *action, GtkRadioAction *current, gpointer data)
904 LayoutWindow *lw = data;
905 gint channel = gtk_radio_action_get_current_value(action);
906 GtkToggleAction *histogram_action = GTK_TOGGLE_ACTION(gtk_action_group_get_action(lw->action_group, "ImageHistogram"));
908 if (channel < 0 || channel >= HCHAN_COUNT) return;
910 gtk_toggle_action_set_active(histogram_action, TRUE); /* this calls layout_menu_histogram_cb */
911 image_osd_histogram_set_channel(lw->image, channel);
914 static void layout_menu_histogram_mode_cb(GtkRadioAction *action, GtkRadioAction *current, gpointer data)
916 LayoutWindow *lw = data;
917 gint mode = gtk_radio_action_get_current_value(action);
918 GtkToggleAction *histogram_action = GTK_TOGGLE_ACTION(gtk_action_group_get_action(lw->action_group, "ImageHistogram"));
920 if (mode < 0 || mode > 1) return;
922 gtk_toggle_action_set_active(histogram_action, TRUE); /* this calls layout_menu_histogram_cb */
923 image_osd_histogram_set_mode(lw->image, mode);
926 static void layout_menu_refresh_cb(GtkAction *action, gpointer data)
928 LayoutWindow *lw = data;
933 static void layout_menu_bar_exif_cb(GtkAction *action, gpointer data)
935 LayoutWindow *lw = data;
937 layout_exit_fullscreen(lw);
938 layout_exif_window_new(lw);
941 static void layout_menu_float_cb(GtkToggleAction *action, gpointer data)
943 LayoutWindow *lw = data;
945 if (lw->options.tools_float == gtk_toggle_action_get_active(action)) return;
947 layout_exit_fullscreen(lw);
948 layout_tools_float_toggle(lw);
951 static void layout_menu_hide_cb(GtkAction *action, gpointer data)
953 LayoutWindow *lw = data;
955 layout_exit_fullscreen(lw);
956 layout_tools_hide_toggle(lw);
959 static void layout_menu_toolbar_cb(GtkToggleAction *action, gpointer data)
961 LayoutWindow *lw = data;
963 if (lw->options.toolbar_hidden == gtk_toggle_action_get_active(action)) return;
965 layout_exit_fullscreen(lw);
966 layout_toolbar_toggle(lw);
969 static void layout_menu_info_pixel_cb(GtkToggleAction *action, gpointer data)
971 LayoutWindow *lw = data;
973 if (lw->options.show_info_pixel == gtk_toggle_action_get_active(action)) return;
975 layout_exit_fullscreen(lw);
976 layout_info_pixel_set(lw, !lw->options.show_info_pixel);
979 /* NOTE: these callbacks are called also from layout_util_sync_views */
980 static void layout_menu_bar_cb(GtkToggleAction *action, gpointer data)
982 LayoutWindow *lw = data;
984 if (layout_bar_enabled(lw) == gtk_toggle_action_get_active(action)) return;
986 layout_exit_fullscreen(lw);
987 layout_bar_toggle(lw);
990 static void layout_menu_bar_sort_cb(GtkToggleAction *action, gpointer data)
992 LayoutWindow *lw = data;
994 if (layout_bar_sort_enabled(lw) == gtk_toggle_action_get_active(action)) return;
996 layout_exit_fullscreen(lw);
997 layout_bar_sort_toggle(lw);
1000 static void layout_menu_hide_bars_cb(GtkToggleAction *action, gpointer data)
1002 LayoutWindow *lw = data;
1004 layout_bars_hide_toggle(lw);
1007 static void layout_menu_slideshow_cb(GtkToggleAction *action, gpointer data)
1009 LayoutWindow *lw = data;
1011 if (layout_image_slideshow_active(lw) == gtk_toggle_action_get_active(action)) return;
1012 layout_image_slideshow_toggle(lw);
1015 static void layout_menu_slideshow_pause_cb(GtkAction *action, gpointer data)
1017 LayoutWindow *lw = data;
1019 layout_image_slideshow_pause_toggle(lw);
1023 static void layout_menu_stereo_mode_next_cb(GtkAction *action, gpointer data)
1025 LayoutWindow *lw = data;
1026 gint mode = layout_image_stereo_pixbuf_get(lw);
1028 /* 0->1, 1->2, 2->3, 3->1 - disable auto, then cycle */
1029 mode = mode % 3 + 1;
1031 GtkAction *radio = gtk_action_group_get_action(lw->action_group, "StereoAuto");
1032 gtk_radio_action_set_current_value(GTK_RADIO_ACTION(radio), mode);
1035 this is called via fallback in layout_menu_stereo_mode_cb
1036 layout_image_stereo_pixbuf_set(lw, mode);
1041 static void layout_menu_stereo_mode_cb(GtkRadioAction *action, GtkRadioAction *current, gpointer data)
1043 LayoutWindow *lw = data;
1044 gint mode = gtk_radio_action_get_current_value(action);
1045 layout_image_stereo_pixbuf_set(lw, mode);
1048 static void layout_menu_help_cb(GtkAction *action, gpointer data)
1050 LayoutWindow *lw = data;
1052 layout_exit_fullscreen(lw);
1053 help_window_show("index.html");
1056 static void layout_menu_help_keys_cb(GtkAction *action, gpointer data)
1058 LayoutWindow *lw = data;
1060 layout_exit_fullscreen(lw);
1061 help_window_show("GuideReferenceKeyboardShortcuts.html");
1064 static void layout_menu_notes_cb(GtkAction *action, gpointer data)
1066 LayoutWindow *lw = data;
1068 layout_exit_fullscreen(lw);
1069 help_window_show("release_notes");
1072 static char *keyboard_map_hardcoded[][2] = {
1074 {"FastScroll", "<Shift>Left"},
1075 {"Left Border", "<Primary>Left"},
1076 {"Left Border", "<Primary><Shift>Left"},
1077 {"Scroll", "Right"},
1078 {"FastScroll", "<Shift>Right"},
1079 {"Right Border", "<Primary>Right"},
1080 {"Right Border", "<Primary><Shift>Right"},
1082 {"FastScroll", "<Shift>Up"},
1083 {"Uper Border", "<Primary>Up"},
1084 {"Uper Border", "<Primary><Shift>Up"},
1086 {"FastScroll", "<Shift>Down"},
1087 {"Lower Border", "<Primary>Down"},
1088 {"Lower Border", "<Primary><Shift>Down"},
1089 {"Next/Drag", "M1"},
1090 {"FastDrag", "<Shift>M1"},
1091 {"DnD Start", "M2"},
1093 {"PrevImage", "MW4"},
1094 {"NextImage", "MW5"},
1095 {"ScrollUp", "<Shift>MW4"},
1096 {"ScrollDown", "<Shift>MW5"},
1097 {"ZoomIn", "<Primary>MW4"},
1098 {"ZoomOut", "<Primary>MW5"},
1102 static void layout_menu_foreach_func(
1104 const gchar *accel_path,
1106 GdkModifierType accel_mods,
1110 gchar *key_name, *menu_name;
1111 gchar **subset_lt_arr, **subset_gt_arr;
1112 gchar *subset_lt, *converted_name;
1113 GPtrArray *array = data;
1115 path = g_strescape(accel_path, NULL);
1116 name = gtk_accelerator_name(accel_key, accel_mods);
1118 menu_name = g_strdup(g_strrstr(path, "/")+1);
1120 if (g_strrstr(name, ">"))
1122 subset_lt_arr = g_strsplit_set(name,"<", 4);
1123 subset_lt = g_strjoinv("<", subset_lt_arr);
1124 subset_gt_arr = g_strsplit_set(subset_lt,">", 4);
1125 converted_name = g_strjoinv(">", subset_gt_arr);
1126 key_name = g_strdup(converted_name);
1128 g_free(converted_name);
1130 g_strfreev(subset_lt_arr);
1131 g_strfreev(subset_gt_arr);
1134 key_name = g_strdup(name);
1136 g_ptr_array_add(array, (gpointer)menu_name);
1137 g_ptr_array_add(array, (gpointer)key_name);
1143 static void layout_menu_kbd_map_cb(GtkAction *action, gpointer data)
1145 LayoutWindow *lw = data;
1149 GError *error = NULL;
1150 GIOChannel *channel;
1151 char **pre_key, **post_key;
1152 char *key_name, *converted_line;
1153 int keymap_index, index;
1155 fd = g_file_open_tmp("geeqie_keymap_XXXXXX.svg", &tmp_file, &error);
1158 DEBUG_0("Keyboard Map - cannot create file:%s\n",error->message);
1159 g_error_free(error);
1163 array = g_ptr_array_new();
1165 gtk_accel_map_foreach(array, layout_menu_foreach_func);
1167 channel = g_io_channel_unix_new(fd);
1170 while (keymap_template[keymap_index])
1172 if (g_strrstr(keymap_template[keymap_index], ">key:"))
1174 pre_key = g_strsplit(keymap_template[keymap_index],">key:",2);
1175 post_key = g_strsplit(pre_key[1],"<",2);
1179 for (index=0; index < array->len-2; index=index+2)
1181 if (!(g_ascii_strcasecmp(g_ptr_array_index(array,index+1), post_key[0])))
1183 key_name = g_ptr_array_index(array,index+0);
1189 while (keyboard_map_hardcoded[index][0])
1191 if (!(g_strcmp0(keyboard_map_hardcoded[index][1], post_key[0])))
1193 key_name = keyboard_map_hardcoded[index][0];
1199 converted_line = g_strconcat(pre_key[0], ">", key_name, "<", post_key[1], "\n", NULL);
1200 g_io_channel_write_chars(channel, converted_line, -1, NULL, &error);
1201 if (error) {DEBUG_0("Keyboard Map:%s\n",error->message); g_error_free(error);}
1203 g_free(converted_line);
1204 g_strfreev(pre_key);
1205 g_strfreev(post_key);
1209 g_io_channel_write_chars(channel, keymap_template[keymap_index], -1, NULL, &error);
1210 if (error) {DEBUG_0("Keyboard Map:%s\n",error->message); g_error_free(error);}
1211 g_io_channel_write_chars(channel, "\n", -1, NULL, &error);
1212 if (error) {DEBUG_0("Keyboard Map:%s\n",error->message); g_error_free(error);}
1217 g_io_channel_flush(channel, &error);
1218 if (error) {DEBUG_0("Keyboard Map:%s\n",error->message); g_error_free(error);}
1219 g_io_channel_unref(channel);
1222 for (index=0; index < array->len-2; index=index+2)
1224 g_free(g_ptr_array_index(array,index));
1225 g_free(g_ptr_array_index(array,index+1));
1227 g_ptr_array_unref(array);
1229 view_window_new(file_data_new_simple(tmp_file));
1234 static void layout_menu_about_cb(GtkAction *action, gpointer data)
1236 LayoutWindow *lw = data;
1238 layout_exit_fullscreen(lw);
1239 show_about_window();
1242 static void layout_menu_log_window_cb(GtkAction *action, gpointer data)
1244 LayoutWindow *lw = data;
1246 layout_exit_fullscreen(lw);
1252 *-----------------------------------------------------------------------------
1254 *-----------------------------------------------------------------------------
1257 static void layout_menu_select_all_cb(GtkAction *action, gpointer data)
1259 LayoutWindow *lw = data;
1261 layout_select_all(lw);
1264 static void layout_menu_unselect_all_cb(GtkAction *action, gpointer data)
1266 LayoutWindow *lw = data;
1268 layout_select_none(lw);
1271 static void layout_menu_invert_selection_cb(GtkAction *action, gpointer data)
1273 LayoutWindow *lw = data;
1275 layout_select_invert(lw);
1278 static void layout_menu_marks_cb(GtkToggleAction *action, gpointer data)
1280 LayoutWindow *lw = data;
1282 layout_marks_set(lw, gtk_toggle_action_get_active(action));
1286 static void layout_menu_set_mark_sel_cb(GtkAction *action, gpointer data)
1288 LayoutWindow *lw = data;
1289 gint mark = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(action), "mark_num"));
1290 g_assert(mark >= 1 && mark <= FILEDATA_MARKS_SIZE);
1292 layout_selection_to_mark(lw, mark, STM_MODE_SET);
1295 static void layout_menu_res_mark_sel_cb(GtkAction *action, gpointer data)
1297 LayoutWindow *lw = data;
1298 gint mark = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(action), "mark_num"));
1299 g_assert(mark >= 1 && mark <= FILEDATA_MARKS_SIZE);
1301 layout_selection_to_mark(lw, mark, STM_MODE_RESET);
1304 static void layout_menu_toggle_mark_sel_cb(GtkAction *action, gpointer data)
1306 LayoutWindow *lw = data;
1307 gint mark = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(action), "mark_num"));
1308 g_assert(mark >= 1 && mark <= FILEDATA_MARKS_SIZE);
1310 layout_selection_to_mark(lw, mark, STM_MODE_TOGGLE);
1313 static void layout_menu_sel_mark_cb(GtkAction *action, gpointer data)
1315 LayoutWindow *lw = data;
1316 gint mark = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(action), "mark_num"));
1317 g_assert(mark >= 1 && mark <= FILEDATA_MARKS_SIZE);
1319 layout_mark_to_selection(lw, mark, MTS_MODE_SET);
1322 static void layout_menu_sel_mark_or_cb(GtkAction *action, gpointer data)
1324 LayoutWindow *lw = data;
1325 gint mark = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(action), "mark_num"));
1326 g_assert(mark >= 1 && mark <= FILEDATA_MARKS_SIZE);
1328 layout_mark_to_selection(lw, mark, MTS_MODE_OR);
1331 static void layout_menu_sel_mark_and_cb(GtkAction *action, gpointer data)
1333 LayoutWindow *lw = data;
1334 gint mark = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(action), "mark_num"));
1335 g_assert(mark >= 1 && mark <= FILEDATA_MARKS_SIZE);
1337 layout_mark_to_selection(lw, mark, MTS_MODE_AND);
1340 static void layout_menu_sel_mark_minus_cb(GtkAction *action, gpointer data)
1342 LayoutWindow *lw = data;
1343 gint mark = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(action), "mark_num"));
1344 g_assert(mark >= 1 && mark <= FILEDATA_MARKS_SIZE);
1346 layout_mark_to_selection(lw, mark, MTS_MODE_MINUS);
1349 static void layout_menu_mark_filter_toggle_cb(GtkAction *action, gpointer data)
1351 LayoutWindow *lw = data;
1352 gint mark = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(action), "mark_num"));
1353 g_assert(mark >= 1 && mark <= FILEDATA_MARKS_SIZE);
1355 layout_marks_set(lw, TRUE);
1356 layout_mark_filter_toggle(lw, mark);
1361 *-----------------------------------------------------------------------------
1363 *-----------------------------------------------------------------------------
1366 static void layout_menu_image_first_cb(GtkAction *action, gpointer data)
1368 LayoutWindow *lw = data;
1369 layout_image_first(lw);
1372 static void layout_menu_image_prev_cb(GtkAction *action, gpointer data)
1374 LayoutWindow *lw = data;
1375 layout_image_prev(lw);
1378 static void layout_menu_image_next_cb(GtkAction *action, gpointer data)
1380 LayoutWindow *lw = data;
1381 layout_image_next(lw);
1384 static void layout_menu_split_pane_next_cb(GtkAction *action, gpointer data)
1386 LayoutWindow *lw = data;
1389 active_frame = lw->active_split_image;
1391 if (active_frame < MAX_SPLIT_IMAGES-1 && lw->split_images[active_frame+1] )
1399 layout_image_activate(lw, active_frame, FALSE);
1402 static void layout_menu_split_pane_prev_cb(GtkAction *action, gpointer data)
1404 LayoutWindow *lw = data;
1407 active_frame = lw->active_split_image;
1409 if (active_frame >=1 && lw->split_images[active_frame-1] )
1415 active_frame = MAX_SPLIT_IMAGES-1;
1416 while (!lw->split_images[active_frame])
1421 layout_image_activate(lw, active_frame, FALSE);
1424 static void layout_menu_image_last_cb(GtkAction *action, gpointer data)
1426 LayoutWindow *lw = data;
1427 layout_image_last(lw);
1430 static void layout_menu_back_cb(GtkAction *action, gpointer data)
1432 LayoutWindow *lw = data;
1435 GList *list = history_list_get_by_key("path_list");
1441 /* Previous path from history */
1442 path = (gchar *)list->data;
1451 /* Open previous path */
1452 dir_fd = file_data_new_dir(path);
1453 layout_set_fd(lw, dir_fd);
1454 file_data_unref(dir_fd);
1457 static void layout_menu_home_cb(GtkAction *action, gpointer data)
1459 LayoutWindow *lw = data;
1462 if (lw->options.home_path && *lw->options.home_path)
1463 path = lw->options.home_path;
1469 FileData *dir_fd = file_data_new_dir(path);
1470 layout_set_fd(lw, dir_fd);
1471 file_data_unref(dir_fd);
1475 static void layout_menu_up_cb(GtkAction *action, gpointer data)
1477 LayoutWindow *lw = data;
1478 ViewDir *vd = lw->vd;
1481 if (!vd->dir_fd || strcmp(vd->dir_fd->path, G_DIR_SEPARATOR_S) == 0) return;
1482 path = remove_level_from_path(vd->dir_fd->path);
1484 if (vd->select_func)
1486 FileData *fd = file_data_new_dir(path);
1487 vd->select_func(vd, fd, vd->select_data);
1488 file_data_unref(fd);
1496 *-----------------------------------------------------------------------------
1498 *-----------------------------------------------------------------------------
1501 static void layout_menu_edit_cb(GtkAction *action, gpointer data)
1503 LayoutWindow *lw = data;
1504 const gchar *key = gtk_action_get_name(action);
1506 if (!editor_window_flag_set(key))
1507 layout_exit_fullscreen(lw);
1509 file_util_start_editor_from_filelist(key, layout_selection_list(lw), layout_get_path(lw), lw->window);
1513 static void layout_menu_metadata_write_cb(GtkAction *action, gpointer data)
1515 metadata_write_queue_confirm(TRUE, NULL, NULL);
1520 *-----------------------------------------------------------------------------
1521 * color profile button (and menu)
1522 *-----------------------------------------------------------------------------
1525 static void layout_color_menu_enable_cb(GtkToggleAction *action, gpointer data)
1528 LayoutWindow *lw = data;
1530 if (layout_image_color_profile_get_use(lw) == gtk_toggle_action_get_active(action)) return;
1532 layout_image_color_profile_set_use(lw, gtk_toggle_action_get_active(action));
1533 layout_util_sync_color(lw);
1534 layout_image_refresh(lw);
1538 static void layout_color_menu_use_image_cb(GtkToggleAction *action, gpointer data)
1541 LayoutWindow *lw = data;
1545 if (!layout_image_color_profile_get(lw, &input, &use_image)) return;
1546 if (use_image == gtk_toggle_action_get_active(action)) return;
1547 layout_image_color_profile_set(lw, input, gtk_toggle_action_get_active(action));
1548 layout_util_sync_color(lw);
1549 layout_image_refresh(lw);
1553 static void layout_color_menu_input_cb(GtkRadioAction *action, GtkRadioAction *current, gpointer data)
1556 LayoutWindow *lw = data;
1561 type = gtk_radio_action_get_current_value(action);
1562 if (type < 0 || type >= COLOR_PROFILE_FILE + COLOR_PROFILE_INPUTS) return;
1564 if (!layout_image_color_profile_get(lw, &input, &use_image)) return;
1565 if (type == input) return;
1567 layout_image_color_profile_set(lw, type, use_image);
1568 layout_image_refresh(lw);
1574 *-----------------------------------------------------------------------------
1576 *-----------------------------------------------------------------------------
1579 static void layout_menu_recent_cb(GtkWidget *widget, gpointer data)
1584 n = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), "recent_index"));
1586 path = g_list_nth_data(history_list_get_by_key("recent"), n);
1590 /* make a copy of it */
1591 path = g_strdup(path);
1592 collection_window_new(path);
1596 static void layout_menu_recent_update(LayoutWindow *lw)
1604 if (!lw->ui_manager) return;
1606 list = history_list_get_by_key("recent");
1609 menu = gtk_menu_new();
1613 const gchar *filename = filename_from_path((gchar *)list->data);
1615 gboolean free_name = FALSE;
1617 if (file_extension_match(filename, GQ_COLLECTION_EXT))
1619 name = remove_extension_from_path(filename);
1624 name = (gchar *) filename;
1627 item = menu_item_add_simple(menu, name, G_CALLBACK(layout_menu_recent_cb), lw);
1628 if (free_name) g_free(name);
1629 g_object_set_data(G_OBJECT(item), "recent_index", GINT_TO_POINTER(n));
1636 menu_item_add(menu, _("Empty"), NULL, NULL);
1639 recent = gtk_ui_manager_get_widget(lw->ui_manager, "/MainMenu/FileMenu/OpenRecent");
1640 gtk_menu_item_set_submenu(GTK_MENU_ITEM(recent), menu);
1641 gtk_widget_set_sensitive(recent, (n != 0));
1644 void layout_recent_update_all(void)
1648 work = layout_window_list;
1651 LayoutWindow *lw = work->data;
1654 layout_menu_recent_update(lw);
1658 void layout_recent_add_path(const gchar *path)
1662 history_list_add_to_key("recent", path, options->open_recent_list_maxsize);
1664 layout_recent_update_all();
1668 *-----------------------------------------------------------------------------
1670 *-----------------------------------------------------------------------------
1673 #define CB G_CALLBACK
1675 static GtkActionEntry menu_entries[] = {
1676 { "FileMenu", NULL, N_("_File"), NULL, NULL, NULL },
1677 { "GoMenu", NULL, N_("_Go"), NULL, NULL, NULL },
1678 { "EditMenu", NULL, N_("_Edit"), NULL, NULL, NULL },
1679 { "SelectMenu", NULL, N_("_Select"), NULL, NULL, NULL },
1680 { "OrientationMenu", NULL, N_("_Orientation"), NULL, NULL, NULL },
1681 { "RatingMenu", NULL, N_("_Rating"), NULL, NULL, NULL },
1682 { "ExternalMenu", NULL, N_("E_xternal Editors"), NULL, NULL, NULL },
1683 { "PreferencesMenu", NULL, N_("P_references"), NULL, NULL, NULL },
1684 { "ViewMenu", NULL, N_("_View"), NULL, NULL, NULL },
1685 { "FileDirMenu", NULL, N_("_Files and Folders"), NULL, NULL, NULL },
1686 { "ZoomMenu", NULL, N_("_Zoom"), NULL, NULL, NULL },
1687 { "ColorMenu", NULL, N_("_Color Management"), NULL, NULL, NULL },
1688 { "ConnectZoomMenu", NULL, N_("_Connected Zoom"), NULL, NULL, NULL },
1689 { "SplitMenu", NULL, N_("Spli_t"), NULL, NULL, NULL },
1690 { "StereoMenu", NULL, N_("Stere_o"), NULL, NULL, NULL },
1691 { "OverlayMenu", NULL, N_("Image _Overlay"), NULL, NULL, NULL },
1692 { "HelpMenu", NULL, N_("_Help"), NULL, NULL, NULL },
1694 { "FirstImage", GTK_STOCK_GOTO_TOP, N_("_First Image"), "Home", N_("First Image"), CB(layout_menu_image_first_cb) },
1695 { "PrevImage", GTK_STOCK_GO_UP, N_("_Previous Image"), "BackSpace", N_("Previous Image"), CB(layout_menu_image_prev_cb) },
1696 { "PrevImageAlt1", GTK_STOCK_GO_UP, N_("_Previous Image"), "Page_Up", N_("Previous Image"), CB(layout_menu_image_prev_cb) },
1697 { "PrevImageAlt2", GTK_STOCK_GO_UP, N_("_Previous Image"), "KP_Page_Up", N_("Previous Image"), CB(layout_menu_image_prev_cb) },
1698 { "NextImage", GTK_STOCK_GO_DOWN, N_("_Next Image"), "space", N_("Next Image"), CB(layout_menu_image_next_cb) },
1699 { "NextImageAlt1", GTK_STOCK_GO_DOWN, N_("_Next Image"), "Page_Down", N_("Next Image"), CB(layout_menu_image_next_cb) },
1700 { "NextImageAlt2", GTK_STOCK_GO_DOWN, N_("_Next Image"), "KP_Page_Down", N_("Next Image"), CB(layout_menu_image_next_cb) },
1701 { "LastImage", GTK_STOCK_GOTO_BOTTOM, N_("_Last Image"), "End", N_("Last Image"), CB(layout_menu_image_last_cb) },
1702 { "Back", GTK_STOCK_GO_BACK, N_("_Back"), NULL, N_("Back"), CB(layout_menu_back_cb) },
1703 { "Home", GTK_STOCK_HOME, N_("_Home"), NULL, N_("Home"), CB(layout_menu_home_cb) },
1704 { "Up", GTK_STOCK_GO_UP, N_("_Up"), NULL, N_("Up"), CB(layout_menu_up_cb) },
1706 { "NewWindow", GTK_STOCK_NEW, N_("New _window"), "<control>N", N_("New window"), CB(layout_menu_new_window_cb) },
1707 { "NewCollection", GTK_STOCK_INDEX, N_("_New collection"), "C", N_("New collection"), CB(layout_menu_new_cb) },
1708 { "OpenCollection", GTK_STOCK_OPEN, N_("_Open collection..."), "O", N_("Open collection..."), CB(layout_menu_open_cb) },
1709 { "OpenRecent", NULL, N_("Open recen_t"), NULL, N_("Open recent"), NULL },
1710 { "Search", GTK_STOCK_FIND, N_("_Search..."), "F3", N_("Search..."), CB(layout_menu_search_cb) },
1711 { "FindDupes", GTK_STOCK_FIND, N_("_Find duplicates..."), "D", N_("Find duplicates..."), CB(layout_menu_dupes_cb) },
1712 { "PanView", NULL, N_("Pa_n view"), "<control>J", N_("Pan view"), CB(layout_menu_pan_cb) },
1713 { "Print", GTK_STOCK_PRINT, N_("_Print..."), "<shift>P", N_("Print..."), CB(layout_menu_print_cb) },
1714 { "NewFolder", GTK_STOCK_DIRECTORY, N_("N_ew folder..."), "<control>F", N_("New folder..."), CB(layout_menu_dir_cb) },
1715 { "Copy", GTK_STOCK_COPY, N_("_Copy..."), "<control>C", N_("Copy..."), CB(layout_menu_copy_cb) },
1716 { "Move", NULL, N_("_Move..."), "<control>M", N_("Move..."), CB(layout_menu_move_cb) },
1717 { "Rename", NULL, N_("_Rename..."), "<control>R", N_("Rename..."), CB(layout_menu_rename_cb) },
1718 { "Delete", GTK_STOCK_DELETE, N_("_Delete..."), "<control>D", N_("Delete..."), CB(layout_menu_delete_cb) },
1719 { "DeleteAlt1", GTK_STOCK_DELETE, N_("_Delete..."), "Delete", N_("Delete..."), CB(layout_menu_delete_key_cb) },
1720 { "DeleteAlt2", GTK_STOCK_DELETE, N_("_Delete..."), "KP_Delete", N_("Delete..."), CB(layout_menu_delete_key_cb) },
1721 { "EnableGrouping", NULL, N_("Enable file _grouping"), NULL, N_("Enable file grouping"), CB(layout_menu_enable_grouping_cb) },
1722 { "DisableGrouping", NULL, N_("Disable file groupi_ng"), NULL, N_("Disable file grouping"), CB(layout_menu_disable_grouping_cb) },
1723 { "CopyPath", NULL, N_("_Copy path to clipboard"), NULL, N_("Copy path to clipboard"), CB(layout_menu_copy_path_cb) },
1724 { "CloseWindow", GTK_STOCK_CLOSE, N_("C_lose window"), "<control>W", N_("Close window"), CB(layout_menu_close_cb) },
1725 { "Quit", GTK_STOCK_QUIT, N_("_Quit"), "<control>Q", N_("Quit"), CB(layout_menu_exit_cb) },
1726 { "RotateCW", NULL, N_("_Rotate clockwise"), "bracketright", N_("Rotate clockwise"), CB(layout_menu_alter_90_cb) },
1727 { "Rating0", NULL, N_("_Rating 0"), "<alt>KP_0", N_("Rating 0"), CB(layout_menu_rating_0_cb) },
1728 { "Rating1", NULL, N_("_Rating 1"), "<alt>KP_1", N_("Rating 1"), CB(layout_menu_rating_1_cb) },
1729 { "Rating2", NULL, N_("_Rating 2"), "<alt>KP_2", N_("Rating 2"), CB(layout_menu_rating_2_cb) },
1730 { "Rating3", NULL, N_("_Rating 3"), "<alt>KP_3", N_("Rating 3"), CB(layout_menu_rating_3_cb) },
1731 { "Rating4", NULL, N_("_Rating 4"), "<alt>KP_4", N_("Rating 4"), CB(layout_menu_rating_4_cb) },
1732 { "Rating5", NULL, N_("_Rating 5"), "<alt>KP_5", N_("Rating 5"), CB(layout_menu_rating_5_cb) },
1733 { "RatingM1", NULL, N_("_Rating -1"), "<alt>KP_Subtract", N_("Rating -1"), CB(layout_menu_rating_m1_cb) },
1734 { "RotateCCW", NULL, N_("Rotate _counterclockwise"), "bracketleft", N_("Rotate counterclockwise"), CB(layout_menu_alter_90cc_cb) },
1735 { "Rotate180", NULL, N_("Rotate 1_80"), "<shift>R", N_("Rotate 180"), CB(layout_menu_alter_180_cb) },
1736 { "Mirror", NULL, N_("_Mirror"), "<shift>M", N_("Mirror"), CB(layout_menu_alter_mirror_cb) },
1737 { "Flip", NULL, N_("_Flip"), "<shift>F", N_("Flip"), CB(layout_menu_alter_flip_cb) },
1738 { "AlterNone", NULL, N_("_Original state"), "<shift>O", N_("Original state"), CB(layout_menu_alter_none_cb) },
1739 { "SelectAll", NULL, N_("Select _all"), "<control>A", N_("Select all"), CB(layout_menu_select_all_cb) },
1740 { "SelectNone", NULL, N_("Select _none"), "<control><shift>A", N_("Select none"), CB(layout_menu_unselect_all_cb) },
1741 { "SelectInvert", NULL, N_("_Invert Selection"), "<control><shift>I", N_("Invert Selection"), CB(layout_menu_invert_selection_cb) },
1742 { "Preferences", GTK_STOCK_PREFERENCES, N_("P_references..."), "<control>O", N_("Preferences..."), CB(layout_menu_config_cb) },
1743 { "Editors", GTK_STOCK_PREFERENCES, N_("Configure _Editors..."), NULL, N_("Configure Editors..."), CB(layout_menu_editors_cb) },
1744 { "LayoutConfig", GTK_STOCK_PREFERENCES, N_("_Configure this window..."), NULL, N_("Configure this window..."), CB(layout_menu_layout_config_cb) },
1745 { "Maintenance", NULL, N_("_Thumbnail maintenance..."), NULL, N_("Thumbnail maintenance..."), CB(layout_menu_remove_thumb_cb) },
1746 { "Wallpaper", NULL, N_("Set as _wallpaper"), NULL, N_("Set as wallpaper"), CB(layout_menu_wallpaper_cb) },
1747 { "SaveMetadata", GTK_STOCK_SAVE, N_("_Save metadata"), "<control>S", N_("Save metadata"), CB(layout_menu_metadata_write_cb) },
1748 { "ZoomIn", GTK_STOCK_ZOOM_IN, N_("Zoom _in"), "equal", N_("Zoom in"), CB(layout_menu_zoom_in_cb) },
1749 { "ZoomInAlt1", GTK_STOCK_ZOOM_IN, N_("Zoom _in"), "KP_Add", N_("Zoom in"), CB(layout_menu_zoom_in_cb) },
1750 { "ZoomOut", GTK_STOCK_ZOOM_OUT, N_("Zoom _out"), "minus", N_("Zoom out"), CB(layout_menu_zoom_out_cb) },
1751 { "ZoomOutAlt1", GTK_STOCK_ZOOM_OUT, N_("Zoom _out"), "KP_Subtract", N_("Zoom out"), CB(layout_menu_zoom_out_cb) },
1752 { "Zoom100", GTK_STOCK_ZOOM_100, N_("Zoom _1:1"), "Z", N_("Zoom 1:1"), CB(layout_menu_zoom_1_1_cb) },
1753 { "Zoom100Alt1", GTK_STOCK_ZOOM_100, N_("Zoom _1:1"), "KP_Divide", N_("Zoom 1:1"), CB(layout_menu_zoom_1_1_cb) },
1754 { "ZoomFit", GTK_STOCK_ZOOM_FIT, N_("_Zoom to fit"), "X", N_("Zoom to fit"), CB(layout_menu_zoom_fit_cb) },
1755 { "ZoomFitAlt1", GTK_STOCK_ZOOM_FIT, N_("_Zoom to fit"), "KP_Multiply", N_("Zoom to fit"), CB(layout_menu_zoom_fit_cb) },
1756 { "ZoomFillHor", NULL, N_("Fit _Horizontally"), "H", N_("Fit Horizontally"), CB(layout_menu_zoom_fit_hor_cb) },
1757 { "ZoomFillVert", NULL, N_("Fit _Vertically"), "W", N_("Fit Vertically"), CB(layout_menu_zoom_fit_vert_cb) },
1758 { "Zoom200", NULL, N_("Zoom _2:1"), NULL, N_("Zoom 2:1"), CB(layout_menu_zoom_2_1_cb) },
1759 { "Zoom300", NULL, N_("Zoom _3:1"), NULL, N_("Zoom 3:1"), CB(layout_menu_zoom_3_1_cb) },
1760 { "Zoom400", NULL, N_("Zoom _4:1"), NULL, N_("Zoom 4:1"), CB(layout_menu_zoom_4_1_cb) },
1761 { "Zoom50", NULL, N_("Zoom 1:2"), NULL, N_("Zoom 1:2"), CB(layout_menu_zoom_1_2_cb) },
1762 { "Zoom33", NULL, N_("Zoom 1:3"), NULL, N_("Zoom 1:3"), CB(layout_menu_zoom_1_3_cb) },
1763 { "Zoom25", NULL, N_("Zoom 1:4"), NULL, N_("Zoom 1:4"), CB(layout_menu_zoom_1_4_cb) },
1764 { "ConnectZoomIn", GTK_STOCK_ZOOM_IN, N_("Zoom _in"), "plus", N_("Connected Zoom in"), CB(layout_menu_connect_zoom_in_cb) },
1765 { "ConnectZoomInAlt1",GTK_STOCK_ZOOM_IN, N_("Zoom _in"), "<shift>KP_Add", N_("Connected Zoom in"), CB(layout_menu_connect_zoom_in_cb) },
1766 { "ConnectZoomOut", GTK_STOCK_ZOOM_OUT, N_("Zoom _out"), "underscore", N_("Connected Zoom out"), CB(layout_menu_connect_zoom_out_cb) },
1767 { "ConnectZoomOutAlt1",GTK_STOCK_ZOOM_OUT, N_("Zoom _out"), "<shift>KP_Subtract", N_("Connected Zoom out"), CB(layout_menu_connect_zoom_out_cb) },
1768 { "ConnectZoom100", GTK_STOCK_ZOOM_100, N_("Zoom _1:1"), "<shift>Z", N_("Connected Zoom 1:1"), CB(layout_menu_connect_zoom_1_1_cb) },
1769 { "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) },
1770 { "ConnectZoomFit", GTK_STOCK_ZOOM_FIT, N_("_Zoom to fit"), "<shift>X", N_("Connected Zoom to fit"), CB(layout_menu_connect_zoom_fit_cb) },
1771 { "ConnectZoomFitAlt1",GTK_STOCK_ZOOM_FIT, N_("_Zoom to fit"), "<shift>KP_Multiply", N_("Connected Zoom to fit"), CB(layout_menu_connect_zoom_fit_cb) },
1772 { "ConnectZoomFillHor",NULL, N_("Fit _Horizontally"), "<shift>H", N_("Connected Fit Horizontally"), CB(layout_menu_connect_zoom_fit_hor_cb) },
1773 { "ConnectZoomFillVert",NULL, N_("Fit _Vertically"), "<shift>W", N_("Connected Fit Vertically"), CB(layout_menu_connect_zoom_fit_vert_cb) },
1774 { "ConnectZoom200", NULL, N_("Zoom _2:1"), NULL, N_("Connected Zoom 2:1"), CB(layout_menu_connect_zoom_2_1_cb) },
1775 { "ConnectZoom300", NULL, N_("Zoom _3:1"), NULL, N_("Connected Zoom 3:1"), CB(layout_menu_connect_zoom_3_1_cb) },
1776 { "ConnectZoom400", NULL, N_("Zoom _4:1"), NULL, N_("Connected Zoom 4:1"), CB(layout_menu_connect_zoom_4_1_cb) },
1777 { "ConnectZoom50", NULL, N_("Zoom 1:2"), NULL, N_("Connected Zoom 1:2"), CB(layout_menu_connect_zoom_1_2_cb) },
1778 { "ConnectZoom33", NULL, N_("Zoom 1:3"), NULL, N_("Connected Zoom 1:3"), CB(layout_menu_connect_zoom_1_3_cb) },
1779 { "ConnectZoom25", NULL, N_("Zoom 1:4"), NULL, N_("Connected Zoom 1:4"), CB(layout_menu_connect_zoom_1_4_cb) },
1780 { "ViewInNewWindow", NULL, N_("_View in new window"), "<control>V", N_("View in new window"), CB(layout_menu_view_in_new_window_cb) },
1781 { "FullScreen", GTK_STOCK_FULLSCREEN, N_("F_ull screen"), "F", N_("Full screen"), CB(layout_menu_fullscreen_cb) },
1782 { "FullScreenAlt1", GTK_STOCK_FULLSCREEN, N_("F_ull screen"), "V", N_("Full screen"), CB(layout_menu_fullscreen_cb) },
1783 { "FullScreenAlt2", GTK_STOCK_FULLSCREEN, N_("F_ull screen"), "F11", N_("Full screen"), CB(layout_menu_fullscreen_cb) },
1784 { "Escape", GTK_STOCK_LEAVE_FULLSCREEN,N_("_Leave full screen"), "Escape", N_("Leave full screen"), CB(layout_menu_escape_cb) },
1785 { "EscapeAlt1", GTK_STOCK_LEAVE_FULLSCREEN,N_("_Leave full screen"), "Q", N_("Leave full screen"), CB(layout_menu_escape_cb) },
1786 { "ImageOverlayCycle",NULL, N_("_Cycle through overlay modes"), "I", N_("Cycle through Overlay modes"), CB(layout_menu_overlay_toggle_cb) },
1787 { "HistogramChanCycle",NULL, N_("Cycle through histogram ch_annels"),"K", N_("Cycle through histogram channels"), CB(layout_menu_histogram_toggle_channel_cb) },
1788 { "HistogramModeCycle",NULL, N_("Cycle through histogram mo_des"), "J", N_("Cycle through histogram modes"), CB(layout_menu_histogram_toggle_mode_cb) },
1789 { "HideTools", NULL, N_("_Hide file list"), "<control>H", N_("Hide file list"), CB(layout_menu_hide_cb) },
1790 { "SlideShowPause", GTK_STOCK_MEDIA_PAUSE, N_("_Pause slideshow"), "P", N_("Pause slideshow"), CB(layout_menu_slideshow_pause_cb) },
1791 { "Refresh", GTK_STOCK_REFRESH, N_("_Refresh"), "R", N_("Refresh"), CB(layout_menu_refresh_cb) },
1792 { "HelpContents", GTK_STOCK_HELP, N_("_Contents"), "F1", N_("Contents"), CB(layout_menu_help_cb) },
1793 { "HelpShortcuts", NULL, N_("_Keyboard shortcuts"), NULL, N_("Keyboard shortcuts"), CB(layout_menu_help_keys_cb) },
1794 { "HelpKbd", NULL, N_("_Keyboard map"), NULL, N_("Keyboard map"), CB(layout_menu_kbd_map_cb) },
1795 { "HelpNotes", NULL, N_("_Release notes"), NULL, N_("Release notes"), CB(layout_menu_notes_cb) },
1796 { "About", GTK_STOCK_ABOUT, N_("_About"), NULL, N_("About"), CB(layout_menu_about_cb) },
1797 { "LogWindow", NULL, N_("_Log Window"), NULL, N_("Log Window"), CB(layout_menu_log_window_cb) },
1798 { "ExifWin", NULL, N_("_Exif window"), "<control>E", N_("Exif window"), CB(layout_menu_bar_exif_cb) },
1799 { "StereoCycle", NULL, N_("_Cycle through stereo modes"), NULL, N_("Cycle through stereo modes"), CB(layout_menu_stereo_mode_next_cb) },
1800 { "SplitNextPane", NULL, N_("_Next Pane"), "<alt>Right", N_("Next Pane"), CB(layout_menu_split_pane_next_cb) },
1801 { "SplitPreviousPane", NULL, N_("_Previous Pane"), "<alt>Left", N_("Previous Pane"), CB(layout_menu_split_pane_prev_cb) },
1802 { "WriteRotation", NULL, N_("_Write orientation to file"), NULL, N_("Write orientation to file"), CB(layout_menu_write_rotate_cb) },
1803 { "WriteRotationKeepDate", NULL, N_("_Write orientation to file (preserve timestamp)"), NULL, N_("Write orientation to file (preserve timestamp)"), CB(layout_menu_write_rotate_keep_date_cb) },
1807 static GtkToggleActionEntry menu_toggle_entries[] = {
1808 { "Thumbnails", PIXBUF_INLINE_ICON_THUMB,N_("Show _Thumbnails"), "T", N_("Show Thumbnails"), CB(layout_menu_thumb_cb), FALSE },
1809 { "ShowMarks", NULL, N_("Show _Marks"), "M", N_("Show Marks"), CB(layout_menu_marks_cb), FALSE },
1810 { "ShowInfoPixel", GTK_STOCK_COLOR_PICKER, N_("Pi_xel Info"), NULL, N_("Show Pixel Info"), CB(layout_menu_info_pixel_cb), FALSE },
1811 { "FloatTools", PIXBUF_INLINE_ICON_FLOAT,N_("_Float file list"), "L", N_("Float file list"), CB(layout_menu_float_cb), FALSE },
1812 { "HideToolbar", NULL, N_("Hide tool_bar"), NULL, N_("Hide toolbar"), CB(layout_menu_toolbar_cb), FALSE },
1813 { "SBar", NULL, N_("_Info sidebar"), "<control>K", N_("Info sidebar"), CB(layout_menu_bar_cb), FALSE },
1814 { "SBarSort", NULL, N_("Sort _manager"), "<shift>S", N_("Sort manager"), CB(layout_menu_bar_sort_cb), FALSE },
1815 { "HideBars", NULL, N_("Hide Bars"), "grave", N_("Hide Bars"), CB(layout_menu_hide_bars_cb), FALSE },
1816 { "SlideShow", GTK_STOCK_MEDIA_PLAY, N_("Toggle _slideshow"), "S", N_("Toggle slideshow"), CB(layout_menu_slideshow_cb), FALSE },
1817 { "UseColorProfiles", GTK_STOCK_SELECT_COLOR, N_("Use _color profiles"), NULL, N_("Use color profiles"), CB(layout_color_menu_enable_cb), FALSE},
1818 { "UseImageProfile", NULL, N_("Use profile from _image"), NULL, N_("Use profile from image"), CB(layout_color_menu_use_image_cb), FALSE},
1819 { "Grayscale", NULL, N_("Toggle _grayscale"), "<shift>G", N_("Toggle grayscale"), CB(layout_menu_alter_desaturate_cb), FALSE},
1820 { "ImageOverlay", NULL, N_("Image _Overlay"), NULL, N_("Image Overlay"), CB(layout_menu_overlay_cb), FALSE },
1821 { "ImageHistogram", NULL, N_("_Show Histogram"), NULL, N_("Show Histogram"), CB(layout_menu_histogram_cb), FALSE },
1822 { "RectangularSelection", NULL, N_("Rectangular Selection"), "<alt>R", N_("Rectangular Selection"), CB(layout_menu_rectangular_selection_cb), FALSE },
1823 { "Animate", NULL, N_("GIF _animation"), "A", N_("Toggle GIF animation"), CB(layout_menu_animate_cb), FALSE },
1824 { "ExifRotate", GTK_STOCK_ORIENTATION_PORTRAIT, N_("_Exif rotate"), "<alt>X", N_("Exif rotate"), CB(layout_menu_exif_rotate_cb), FALSE },
1827 static GtkRadioActionEntry menu_radio_entries[] = {
1828 { "ViewList", NULL, N_("Image _List"), "<control>L", N_("View Images as List"), FILEVIEW_LIST },
1829 { "ViewIcons", NULL, N_("I_cons"), "<control>I", N_("View Images as Icons"), FILEVIEW_ICON }
1832 static GtkToggleActionEntry menu_view_dir_toggle_entries[] = {
1833 { "FolderTree", NULL, N_("T_oggle Folder View"), "<control>T", N_("Toggle Folders View"), CB(layout_menu_view_dir_as_cb),FALSE },
1836 static GtkRadioActionEntry menu_split_radio_entries[] = {
1837 { "SplitHorizontal", NULL, N_("_Horizontal"), "E", N_("Split Horizontal"), SPLIT_HOR },
1838 { "SplitVertical", NULL, N_("_Vertical"), "U", N_("Split Vertical"), SPLIT_VERT },
1839 { "SplitQuad", NULL, N_("_Quad"), NULL, N_("Split Quad"), SPLIT_QUAD },
1840 { "SplitSingle", NULL, N_("_Single"), "Y", N_("Split Single"), SPLIT_NONE }
1843 static GtkRadioActionEntry menu_color_radio_entries[] = {
1844 { "ColorProfile0", NULL, N_("Input _0: sRGB"), NULL, N_("Input 0: sRGB"), COLOR_PROFILE_SRGB },
1845 { "ColorProfile1", NULL, N_("Input _1: AdobeRGB compatible"), NULL, N_("Input 1: AdobeRGB compatible"), COLOR_PROFILE_ADOBERGB },
1846 { "ColorProfile2", NULL, N_("Input _2"), NULL, N_("Input 2"), COLOR_PROFILE_FILE },
1847 { "ColorProfile3", NULL, N_("Input _3"), NULL, N_("Input 3"), COLOR_PROFILE_FILE + 1 },
1848 { "ColorProfile4", NULL, N_("Input _4"), NULL, N_("Input 4"), COLOR_PROFILE_FILE + 2 },
1849 { "ColorProfile5", NULL, N_("Input _5"), NULL, N_("Input 5"), COLOR_PROFILE_FILE + 3 }
1852 static GtkRadioActionEntry menu_histogram_channel[] = {
1853 { "HistogramChanR", NULL, N_("Histogram on _Red"), NULL, N_("Histogram on Red"), HCHAN_R },
1854 { "HistogramChanG", NULL, N_("Histogram on _Green"), NULL, N_("Histogram on Green"), HCHAN_G },
1855 { "HistogramChanB", NULL, N_("Histogram on _Blue"), NULL, N_("Histogram on Blue"), HCHAN_B },
1856 { "HistogramChanRGB", NULL, N_("_Histogram on RGB"), NULL, N_("Histogram on RGB"), HCHAN_RGB },
1857 { "HistogramChanV", NULL, N_("Histogram on _Value"), NULL, N_("Histogram on Value"), HCHAN_MAX }
1860 static GtkRadioActionEntry menu_histogram_mode[] = {
1861 { "HistogramModeLin", NULL, N_("Li_near Histogram"), NULL, N_("Linear Histogram"), 0 },
1862 { "HistogramModeLog", NULL, N_("_Log Histogram"), NULL, N_("Log Histogram"), 1 },
1865 static GtkRadioActionEntry menu_stereo_mode_entries[] = {
1866 { "StereoAuto", NULL, N_("_Auto"), NULL, N_("Stereo Auto"), STEREO_PIXBUF_DEFAULT },
1867 { "StereoSBS", NULL, N_("_Side by Side"), NULL, N_("Stereo Side by Side"), STEREO_PIXBUF_SBS },
1868 { "StereoCross", NULL, N_("_Cross"), NULL, N_("Stereo Cross"), STEREO_PIXBUF_CROSS },
1869 { "StereoOff", NULL, N_("_Off"), NULL, N_("Stereo Off"), STEREO_PIXBUF_NONE }
1875 static const gchar *menu_ui_description =
1877 " <menubar name='MainMenu'>"
1878 " <menu action='FileMenu'>"
1879 " <menuitem action='NewWindow'/>"
1880 " <menuitem action='NewCollection'/>"
1881 " <menuitem action='OpenCollection'/>"
1882 " <menuitem action='OpenRecent'/>"
1883 " <placeholder name='OpenSection'/>"
1885 " <menuitem action='Search'/>"
1886 " <menuitem action='FindDupes'/>"
1887 " <placeholder name='SearchSection'/>"
1889 " <menuitem action='Print'/>"
1890 " <placeholder name='PrintSection'/>"
1892 " <menuitem action='NewFolder'/>"
1893 " <menuitem action='Copy'/>"
1894 " <menuitem action='Move'/>"
1895 " <menuitem action='Rename'/>"
1896 " <menuitem action='Delete'/>"
1897 " <placeholder name='FileOpsSection'/>"
1899 " <placeholder name='QuitSection'/>"
1900 " <menuitem action='CloseWindow'/>"
1901 " <menuitem action='Quit'/>"
1904 " <menu action='GoMenu'>"
1905 " <menuitem action='FirstImage'/>"
1906 " <menuitem action='PrevImage'/>"
1907 " <menuitem action='NextImage'/>"
1908 " <menuitem action='LastImage'/>"
1910 " <menuitem action='Back'/>"
1911 " <menuitem action='Up'/>"
1912 " <menuitem action='Home'/>"
1915 " <menu action='SelectMenu'>"
1916 " <menuitem action='SelectAll'/>"
1917 " <menuitem action='SelectNone'/>"
1918 " <menuitem action='SelectInvert'/>"
1919 " <menuitem action='RectangularSelection'/>"
1920 " <placeholder name='SelectSection'/>"
1922 " <menuitem action='CopyPath'/>"
1923 " <placeholder name='ClipboardSection'/>"
1925 " <menuitem action='ShowMarks'/>"
1926 " <placeholder name='MarksSection'/>"
1929 " <menu action='EditMenu'>"
1930 " <menu action='ExternalMenu'>"
1932 " <placeholder name='EditSection'/>"
1934 " <menu action='OrientationMenu'>"
1935 " <menuitem action='RotateCW'/>"
1936 " <menuitem action='RotateCCW'/>"
1937 " <menuitem action='Rotate180'/>"
1938 " <menuitem action='Mirror'/>"
1939 " <menuitem action='Flip'/>"
1940 " <menuitem action='AlterNone'/>"
1942 " <menuitem action='ExifRotate'/>"
1944 " <menuitem action='WriteRotation'/>"
1945 " <menuitem action='WriteRotationKeepDate'/>"
1948 " <menu action='RatingMenu'>"
1949 " <menuitem action='Rating0'/>"
1950 " <menuitem action='Rating1'/>"
1951 " <menuitem action='Rating2'/>"
1952 " <menuitem action='Rating3'/>"
1953 " <menuitem action='Rating4'/>"
1954 " <menuitem action='Rating5'/>"
1955 " <menuitem action='RatingM1'/>"
1958 " <menuitem action='SaveMetadata'/>"
1959 " <placeholder name='PropertiesSection'/>"
1961 " <menu action='PreferencesMenu'>"
1962 " <menuitem action='Preferences'/>"
1963 " <menuitem action='Editors'/>"
1964 " <menuitem action='LayoutConfig'/>"
1965 " <menuitem action='Maintenance'/>"
1967 " <placeholder name='PreferencesSection'/>"
1969 #if !GTK_CHECK_VERSION(3,0,0)
1970 " <menuitem action='Wallpaper'/>"
1974 " <menu action='ViewMenu'>"
1975 " <menuitem action='ViewInNewWindow'/>"
1976 " <menuitem action='PanView'/>"
1977 " <menuitem action='ExifWin'/>"
1978 " <placeholder name='WindowSection'/>"
1980 " <menu action='FileDirMenu'>"
1981 " <menuitem action='FolderTree'/>"
1982 " <placeholder name='FolderSection'/>"
1984 " <menuitem action='ViewList'/>"
1985 " <menuitem action='ViewIcons'/>"
1986 " <menuitem action='Thumbnails'/>"
1987 " <placeholder name='ListSection'/>"
1989 " <menuitem action='FloatTools'/>"
1990 " <menuitem action='HideTools'/>"
1991 " <menuitem action='HideToolbar'/>"
1993 " <placeholder name='DirSection'/>"
1995 " <menu action='ZoomMenu'>"
1996 " <menu action='ConnectZoomMenu'>"
1997 " <menuitem action='ConnectZoomIn'/>"
1998 " <menuitem action='ConnectZoomOut'/>"
1999 " <menuitem action='ConnectZoomFit'/>"
2000 " <menuitem action='ConnectZoomFillHor'/>"
2001 " <menuitem action='ConnectZoomFillVert'/>"
2002 " <menuitem action='ConnectZoom100'/>"
2003 " <menuitem action='ConnectZoom200'/>"
2004 " <menuitem action='ConnectZoom300'/>"
2005 " <menuitem action='ConnectZoom400'/>"
2006 " <menuitem action='ConnectZoom50'/>"
2007 " <menuitem action='ConnectZoom33'/>"
2008 " <menuitem action='ConnectZoom25'/>"
2010 " <menuitem action='ZoomIn'/>"
2011 " <menuitem action='ZoomOut'/>"
2012 " <menuitem action='ZoomFit'/>"
2013 " <menuitem action='ZoomFillHor'/>"
2014 " <menuitem action='ZoomFillVert'/>"
2015 " <menuitem action='Zoom100'/>"
2016 " <menuitem action='Zoom200'/>"
2017 " <menuitem action='Zoom300'/>"
2018 " <menuitem action='Zoom400'/>"
2019 " <menuitem action='Zoom50'/>"
2020 " <menuitem action='Zoom33'/>"
2021 " <menuitem action='Zoom25'/>"
2023 " <menu action='SplitMenu'>"
2024 " <menuitem action='SplitHorizontal'/>"
2025 " <menuitem action='SplitVertical'/>"
2026 " <menuitem action='SplitQuad'/>"
2027 " <menuitem action='SplitSingle'/>"
2029 " <menuitem action='SplitNextPane'/>"
2030 " <menuitem action='SplitPreviousPane'/>"
2032 " <menu action='StereoMenu'>"
2033 " <menuitem action='StereoAuto'/>"
2034 " <menuitem action='StereoSBS'/>"
2035 " <menuitem action='StereoCross'/>"
2036 " <menuitem action='StereoOff'/>"
2038 " <menuitem action='StereoCycle'/>"
2040 " <menu action='ColorMenu'>"
2041 " <menuitem action='UseColorProfiles'/>"
2042 " <menuitem action='UseImageProfile'/>"
2043 " <menuitem action='ColorProfile0'/>"
2044 " <menuitem action='ColorProfile1'/>"
2045 " <menuitem action='ColorProfile2'/>"
2046 " <menuitem action='ColorProfile3'/>"
2047 " <menuitem action='ColorProfile4'/>"
2048 " <menuitem action='ColorProfile5'/>"
2050 " <menuitem action='Grayscale'/>"
2052 " <menu action='OverlayMenu'>"
2053 " <menuitem action='ImageOverlay'/>"
2054 " <menuitem action='ImageHistogram'/>"
2055 " <menuitem action='ImageOverlayCycle'/>"
2057 " <menuitem action='HistogramChanR'/>"
2058 " <menuitem action='HistogramChanG'/>"
2059 " <menuitem action='HistogramChanB'/>"
2060 " <menuitem action='HistogramChanRGB'/>"
2061 " <menuitem action='HistogramChanV'/>"
2062 " <menuitem action='HistogramChanCycle'/>"
2064 " <menuitem action='HistogramModeLin'/>"
2065 " <menuitem action='HistogramModeLog'/>"
2066 " <menuitem action='HistogramModeCycle'/>"
2068 " <menuitem action='FullScreen'/>"
2069 " <placeholder name='ViewSection'/>"
2071 " <menuitem action='SBar'/>"
2072 " <menuitem action='SBarSort'/>"
2073 " <menuitem action='HideBars'/>"
2074 " <menuitem action='ShowInfoPixel'/>"
2075 " <placeholder name='ToolsSection'/>"
2077 " <menuitem action='Animate'/>"
2078 " <menuitem action='SlideShow'/>"
2079 " <menuitem action='SlideShowPause'/>"
2080 " <menuitem action='Refresh'/>"
2081 " <placeholder name='SlideShowSection'/>"
2084 " <menu action='HelpMenu'>"
2086 " <menuitem action='HelpContents'/>"
2087 " <menuitem action='HelpShortcuts'/>"
2088 " <menuitem action='HelpKbd'/>"
2089 " <menuitem action='HelpNotes'/>"
2090 " <placeholder name='HelpSection'/>"
2092 " <menuitem action='About'/>"
2094 " <menuitem action='LogWindow'/>"
2098 " <toolbar name='ToolBar'>"
2099 " <toolitem action='Thumbnails'/>"
2100 " <toolitem action='Back'/>"
2101 " <toolitem action='Up'/>"
2102 " <toolitem action='Home'/>"
2103 " <toolitem action='Refresh'/>"
2104 " <toolitem action='ZoomIn'/>"
2105 " <toolitem action='ZoomOut'/>"
2106 " <toolitem action='ZoomFit'/>"
2107 " <toolitem action='Zoom100'/>"
2108 " <toolitem action='Preferences'/>"
2109 " <toolitem action='FloatTools'/>"
2111 " <toolbar name='StatusBar'>"
2112 " <toolitem action='ExifRotate'/>"
2113 " <toolitem action='ShowInfoPixel'/>"
2114 " <toolitem action='UseColorProfiles'/>"
2115 " <toolitem action='SaveMetadata'/>"
2117 "<accelerator action='PrevImageAlt1'/>"
2118 "<accelerator action='PrevImageAlt2'/>"
2119 "<accelerator action='NextImageAlt1'/>"
2120 "<accelerator action='NextImageAlt2'/>"
2121 "<accelerator action='DeleteAlt1'/>"
2122 "<accelerator action='DeleteAlt2'/>"
2123 "<accelerator action='FullScreenAlt1'/>"
2124 "<accelerator action='FullScreenAlt2'/>"
2125 "<accelerator action='Escape'/>"
2126 "<accelerator action='EscapeAlt1'/>"
2128 "<accelerator action='ZoomInAlt1'/>"
2129 "<accelerator action='ZoomOutAlt1'/>"
2130 "<accelerator action='Zoom100Alt1'/>"
2131 "<accelerator action='ZoomFitAlt1'/>"
2133 "<accelerator action='ConnectZoomInAlt1'/>"
2134 "<accelerator action='ConnectZoomOutAlt1'/>"
2135 "<accelerator action='ConnectZoom100Alt1'/>"
2136 "<accelerator action='ConnectZoomFitAlt1'/>"
2139 static gchar *menu_translate(const gchar *path, gpointer data)
2141 return (gchar *)(_(path));
2144 static void layout_actions_setup_mark(LayoutWindow *lw, gint mark, gchar *name_tmpl,
2145 gchar *label_tmpl, gchar *accel_tmpl, gchar *tooltip_tmpl, GCallback cb)
2151 GtkActionEntry entry = { name, NULL, label, accel, tooltip, cb };
2154 g_snprintf(name, sizeof(name), name_tmpl, mark);
2155 g_snprintf(label, sizeof(label), label_tmpl, mark);
2158 g_snprintf(accel, sizeof(accel), accel_tmpl, mark % 10);
2160 entry.accelerator = NULL;
2163 g_snprintf(tooltip, sizeof(tooltip), tooltip_tmpl, mark);
2165 entry.tooltip = NULL;
2167 gtk_action_group_add_actions(lw->action_group, &entry, 1, lw);
2168 action = gtk_action_group_get_action(lw->action_group, name);
2169 g_object_set_data(G_OBJECT(action), "mark_num", GINT_TO_POINTER(mark));
2172 static void layout_actions_setup_marks(LayoutWindow *lw)
2176 GString *desc = g_string_new(
2178 " <menubar name='MainMenu'>"
2179 " <menu action='SelectMenu'>");
2181 for (mark = 1; mark <= FILEDATA_MARKS_SIZE; mark++)
2183 layout_actions_setup_mark(lw, mark, "Mark%d", _("Mark _%d"), NULL, NULL, NULL);
2184 layout_actions_setup_mark(lw, mark, "SetMark%d", _("_Set mark %d"), NULL, _("Set mark %d"), G_CALLBACK(layout_menu_set_mark_sel_cb));
2185 layout_actions_setup_mark(lw, mark, "ResetMark%d", _("_Reset mark %d"), NULL, _("Reset mark %d"), G_CALLBACK(layout_menu_res_mark_sel_cb));
2186 layout_actions_setup_mark(lw, mark, "ToggleMark%d", _("_Toggle mark %d"), "%d", _("Toggle mark %d"), G_CALLBACK(layout_menu_toggle_mark_sel_cb));
2187 layout_actions_setup_mark(lw, mark, "ToggleMark%dAlt1", _("_Toggle mark %d"), "KP_%d", _("Toggle mark %d"), G_CALLBACK(layout_menu_toggle_mark_sel_cb));
2188 layout_actions_setup_mark(lw, mark, "SelectMark%d", _("Se_lect mark %d"), "<control>%d", _("Select mark %d"), G_CALLBACK(layout_menu_sel_mark_cb));
2189 layout_actions_setup_mark(lw, mark, "SelectMark%dAlt1", _("_Select mark %d"), "<control>KP_%d", _("Select mark %d"), G_CALLBACK(layout_menu_sel_mark_cb));
2190 layout_actions_setup_mark(lw, mark, "AddMark%d", _("_Add mark %d"), NULL, _("Add mark %d"), G_CALLBACK(layout_menu_sel_mark_or_cb));
2191 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));
2192 layout_actions_setup_mark(lw, mark, "UnselMark%d", _("_Unselect mark %d"), NULL, _("Unselect mark %d"), G_CALLBACK(layout_menu_sel_mark_minus_cb));
2193 layout_actions_setup_mark(lw, mark, "FilterMark%d", _("_Filter mark %d"), NULL, _("Filter mark %d"), G_CALLBACK(layout_menu_mark_filter_toggle_cb));
2195 g_string_append_printf(desc,
2196 " <menu action='Mark%d'>"
2197 " <menuitem action='ToggleMark%d'/>"
2198 " <menuitem action='SetMark%d'/>"
2199 " <menuitem action='ResetMark%d'/>"
2201 " <menuitem action='SelectMark%d'/>"
2202 " <menuitem action='AddMark%d'/>"
2203 " <menuitem action='IntMark%d'/>"
2204 " <menuitem action='UnselMark%d'/>"
2206 " <menuitem action='FilterMark%d'/>"
2208 mark, mark, mark, mark, mark, mark, mark, mark, mark);
2211 g_string_append(desc,
2214 for (mark = 1; mark <= FILEDATA_MARKS_SIZE; mark++)
2216 g_string_append_printf(desc,
2217 "<accelerator action='ToggleMark%dAlt1'/>"
2218 "<accelerator action='SelectMark%dAlt1'/>",
2221 g_string_append(desc, "</ui>" );
2224 if (!gtk_ui_manager_add_ui_from_string(lw->ui_manager, desc->str, -1, &error))
2226 g_message("building menus failed: %s", error->message);
2227 g_error_free(error);
2230 g_string_free(desc, TRUE);
2233 static GList *layout_actions_editor_menu_path(EditorDescription *editor)
2235 gchar **split = g_strsplit(editor->menu_path, "/", 0);
2239 if (split[0] == NULL)
2247 ret = g_list_prepend(ret, g_strdup(split[i]));
2253 ret = g_list_prepend(ret, g_strdup(editor->key));
2255 return g_list_reverse(ret);
2258 static void layout_actions_editor_add(GString *desc, GList *path, GList *old_path)
2260 gint to_open, to_close, i;
2261 while (path && old_path && strcmp((gchar *)path->data, (gchar *)old_path->data) == 0)
2264 old_path = old_path->next;
2266 to_open = g_list_length(path) - 1;
2267 to_close = g_list_length(old_path) - 1;
2271 old_path = g_list_last(old_path);
2272 old_path = old_path->prev;
2275 for (i = 0; i < to_close; i++)
2277 gchar *name = old_path->data;
2278 if (g_str_has_suffix(name, "Section"))
2280 g_string_append(desc, " </placeholder>");
2282 else if (g_str_has_suffix(name, "Menu"))
2284 g_string_append(desc, " </menu>");
2288 g_warning("invalid menu path item %s", name);
2290 old_path = old_path->prev;
2293 for (i = 0; i < to_open; i++)
2295 gchar *name = path->data;
2296 if (g_str_has_suffix(name, "Section"))
2298 g_string_append_printf(desc, " <placeholder name='%s'>", name);
2300 else if (g_str_has_suffix(name, "Menu"))
2302 g_string_append_printf(desc, " <menu action='%s'>", name);
2306 g_warning("invalid menu path item %s", name);
2312 g_string_append_printf(desc, " <menuitem action='%s'/>", (gchar *)path->data);
2315 static void layout_actions_setup_editors(LayoutWindow *lw)
2318 GList *editors_list;
2323 if (lw->ui_editors_id)
2325 gtk_ui_manager_remove_ui(lw->ui_manager, lw->ui_editors_id);
2328 if (lw->action_group_editors)
2330 gtk_ui_manager_remove_action_group(lw->ui_manager, lw->action_group_editors);
2331 g_object_unref(lw->action_group_editors);
2333 lw->action_group_editors = gtk_action_group_new("MenuActionsExternal");
2334 gtk_ui_manager_insert_action_group(lw->ui_manager, lw->action_group_editors, 1);
2336 /* lw->action_group_editors contains translated entries, no translate func is required */
2337 desc = g_string_new(
2339 " <menubar name='MainMenu'>");
2341 editors_list = editor_list_get();
2344 work = editors_list;
2348 EditorDescription *editor = work->data;
2349 GtkActionEntry entry = { editor->key,
2353 editor->comment ? editor->comment : editor->name,
2354 G_CALLBACK(layout_menu_edit_cb) };
2358 entry.stock_id = editor->key;
2360 gtk_action_group_add_actions(lw->action_group_editors, &entry, 1, lw);
2362 path = layout_actions_editor_menu_path(editor);
2363 layout_actions_editor_add(desc, path, old_path);
2365 string_list_free(old_path);
2370 layout_actions_editor_add(desc, NULL, old_path);
2371 string_list_free(old_path);
2373 g_string_append(desc, " </menubar>"
2378 lw->ui_editors_id = gtk_ui_manager_add_ui_from_string(lw->ui_manager, desc->str, -1, &error);
2379 if (!lw->ui_editors_id)
2381 g_message("building menus failed: %s", error->message);
2382 g_error_free(error);
2385 g_string_free(desc, TRUE);
2386 g_list_free(editors_list);
2389 void layout_actions_setup(LayoutWindow *lw)
2394 DEBUG_1("%s layout_actions_setup: start", get_exec_time());
2395 if (lw->ui_manager) return;
2397 lw->action_group = gtk_action_group_new("MenuActions");
2398 gtk_action_group_set_translate_func(lw->action_group, menu_translate, NULL, NULL);
2400 gtk_action_group_add_actions(lw->action_group,
2401 menu_entries, G_N_ELEMENTS(menu_entries), lw);
2402 gtk_action_group_add_toggle_actions(lw->action_group,
2403 menu_toggle_entries, G_N_ELEMENTS(menu_toggle_entries), lw);
2404 gtk_action_group_add_radio_actions(lw->action_group,
2405 menu_radio_entries, G_N_ELEMENTS(menu_radio_entries),
2406 0, G_CALLBACK(layout_menu_list_cb), lw);
2407 gtk_action_group_add_radio_actions(lw->action_group,
2408 menu_split_radio_entries, G_N_ELEMENTS(menu_split_radio_entries),
2409 0, G_CALLBACK(layout_menu_split_cb), lw);
2410 gtk_action_group_add_toggle_actions(lw->action_group,
2411 menu_view_dir_toggle_entries, G_N_ELEMENTS(menu_view_dir_toggle_entries),
2413 gtk_action_group_add_radio_actions(lw->action_group,
2414 menu_color_radio_entries, COLOR_PROFILE_FILE + COLOR_PROFILE_INPUTS,
2415 0, G_CALLBACK(layout_color_menu_input_cb), lw);
2416 gtk_action_group_add_radio_actions(lw->action_group,
2417 menu_histogram_channel, G_N_ELEMENTS(menu_histogram_channel),
2418 0, G_CALLBACK(layout_menu_histogram_channel_cb), lw);
2419 gtk_action_group_add_radio_actions(lw->action_group,
2420 menu_histogram_mode, G_N_ELEMENTS(menu_histogram_mode),
2421 0, G_CALLBACK(layout_menu_histogram_mode_cb), lw);
2422 gtk_action_group_add_radio_actions(lw->action_group,
2423 menu_stereo_mode_entries, G_N_ELEMENTS(menu_stereo_mode_entries),
2424 0, G_CALLBACK(layout_menu_stereo_mode_cb), lw);
2427 lw->ui_manager = gtk_ui_manager_new();
2428 gtk_ui_manager_set_add_tearoffs(lw->ui_manager, TRUE);
2429 gtk_ui_manager_insert_action_group(lw->ui_manager, lw->action_group, 0);
2431 DEBUG_1("%s layout_actions_setup: add menu", get_exec_time());
2433 if (!gtk_ui_manager_add_ui_from_string(lw->ui_manager, menu_ui_description, -1, &error))
2435 g_message("building menus failed: %s", error->message);
2436 g_error_free(error);
2440 DEBUG_1("%s layout_actions_setup: marks", get_exec_time());
2441 layout_actions_setup_marks(lw);
2443 DEBUG_1("%s layout_actions_setup: editors", get_exec_time());
2444 layout_actions_setup_editors(lw);
2446 DEBUG_1("%s layout_actions_setup: status_update_write", get_exec_time());
2447 layout_util_status_update_write(lw);
2449 DEBUG_1("%s layout_actions_setup: actions_add_window", get_exec_time());
2450 layout_actions_add_window(lw, lw->window);
2451 DEBUG_1("%s layout_actions_setup: end", get_exec_time());
2454 static gint layout_editors_reload_idle_id = -1;
2455 static GList *layout_editors_desktop_files = NULL;
2457 static gboolean layout_editors_reload_idle_cb(gpointer data)
2459 if (!layout_editors_desktop_files)
2461 DEBUG_1("%s layout_editors_reload_idle_cb: get_desktop_files", get_exec_time());
2462 layout_editors_desktop_files = editor_get_desktop_files();
2466 editor_read_desktop_file(layout_editors_desktop_files->data);
2467 g_free(layout_editors_desktop_files->data);
2468 layout_editors_desktop_files = g_list_delete_link(layout_editors_desktop_files, layout_editors_desktop_files);
2471 if (!layout_editors_desktop_files)
2474 DEBUG_1("%s layout_editors_reload_idle_cb: setup_editors", get_exec_time());
2475 editor_table_finish();
2477 work = layout_window_list;
2480 LayoutWindow *lw = work->data;
2482 layout_actions_setup_editors(lw);
2485 DEBUG_1("%s layout_editors_reload_idle_cb: setup_editors done", get_exec_time());
2487 layout_editors_reload_idle_id = -1;
2493 void layout_editors_reload_start(void)
2495 DEBUG_1("%s layout_editors_reload_start", get_exec_time());
2497 if (layout_editors_reload_idle_id != -1)
2499 g_source_remove(layout_editors_reload_idle_id);
2500 string_list_free(layout_editors_desktop_files);
2503 editor_table_clear();
2504 layout_editors_reload_idle_id = g_idle_add(layout_editors_reload_idle_cb, NULL);
2507 void layout_editors_reload_finish(void)
2509 if (layout_editors_reload_idle_id != -1)
2511 DEBUG_1("%s layout_editors_reload_finish", get_exec_time());
2512 g_source_remove(layout_editors_reload_idle_id);
2513 while (layout_editors_reload_idle_id != -1)
2515 layout_editors_reload_idle_cb(NULL);
2520 void layout_actions_add_window(LayoutWindow *lw, GtkWidget *window)
2522 GtkAccelGroup *group;
2524 if (!lw->ui_manager) return;
2526 group = gtk_ui_manager_get_accel_group(lw->ui_manager);
2527 gtk_window_add_accel_group(GTK_WINDOW(window), group);
2530 GtkWidget *layout_actions_menu_bar(LayoutWindow *lw)
2532 if (lw->menu_bar) return lw->menu_bar;
2533 lw->menu_bar = gtk_ui_manager_get_widget(lw->ui_manager, "/MainMenu");
2534 g_object_ref(lw->menu_bar);
2535 return lw->menu_bar;
2538 GtkWidget *layout_actions_toolbar(LayoutWindow *lw, ToolbarType type)
2540 if (lw->toolbar[type]) return lw->toolbar[type];
2544 lw->toolbar[type] = gtk_ui_manager_get_widget(lw->ui_manager, "/ToolBar");
2545 gtk_toolbar_set_icon_size(GTK_TOOLBAR(lw->toolbar[type]), GTK_ICON_SIZE_SMALL_TOOLBAR);
2546 gtk_toolbar_set_style(GTK_TOOLBAR(lw->toolbar[type]), GTK_TOOLBAR_ICONS);
2548 case TOOLBAR_STATUS:
2549 lw->toolbar[type] = gtk_ui_manager_get_widget(lw->ui_manager, "/StatusBar");
2550 gtk_toolbar_set_icon_size(GTK_TOOLBAR(lw->toolbar[type]), GTK_ICON_SIZE_MENU);
2551 gtk_toolbar_set_style(GTK_TOOLBAR(lw->toolbar[type]), GTK_TOOLBAR_ICONS);
2552 gtk_toolbar_set_show_arrow(GTK_TOOLBAR(lw->toolbar[type]), FALSE);
2557 g_object_ref(lw->toolbar[type]);
2558 return lw->toolbar[type];
2562 *-----------------------------------------------------------------------------
2564 *-----------------------------------------------------------------------------
2567 void layout_util_status_update_write(LayoutWindow *lw)
2570 gint n = metadata_queue_length();
2571 action = gtk_action_group_get_action(lw->action_group, "SaveMetadata");
2572 gtk_action_set_sensitive(action, n > 0);
2575 gchar *buf = g_strdup_printf(_("Number of files with unsaved metadata: %d"), n);
2576 g_object_set(G_OBJECT(action), "tooltip", buf, NULL);
2581 g_object_set(G_OBJECT(action), "tooltip", _("No unsaved metadata"), NULL);
2585 void layout_util_status_update_write_all(void)
2589 work = layout_window_list;
2592 LayoutWindow *lw = work->data;
2595 layout_util_status_update_write(lw);
2599 static gchar *layout_color_name_parse(const gchar *name)
2601 if (!name || !*name) return g_strdup(_("Empty"));
2602 return g_strdelimit(g_strdup(name), "_", '-');
2605 void layout_util_sync_color(LayoutWindow *lw)
2610 gboolean use_image = FALSE;
2612 gchar action_name[15];
2613 gchar *image_profile;
2614 gchar *screen_profile;
2617 if (!lw->action_group) return;
2618 if (!layout_image_color_profile_get(lw, &input, &use_image)) return;
2620 use_color = layout_image_color_profile_get_use(lw);
2622 action = gtk_action_group_get_action(lw->action_group, "UseColorProfiles");
2624 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), use_color);
2625 if (layout_image_color_profile_get_status(lw, &image_profile, &screen_profile))
2628 buf = g_strdup_printf(_("Image profile: %s\nScreen profile: %s"), image_profile, screen_profile);
2629 g_object_set(G_OBJECT(action), "tooltip", buf, NULL);
2630 g_free(image_profile);
2631 g_free(screen_profile);
2636 g_object_set(G_OBJECT(action), "tooltip", _("Click to enable color management"), NULL);
2639 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), FALSE);
2640 gtk_action_set_sensitive(action, FALSE);
2641 g_object_set(G_OBJECT(action), "tooltip", _("Color profiles not supported"), NULL);
2644 action = gtk_action_group_get_action(lw->action_group, "UseImageProfile");
2645 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), use_image);
2646 gtk_action_set_sensitive(action, use_color);
2648 for (i = 0; i < COLOR_PROFILE_FILE + COLOR_PROFILE_INPUTS; i++)
2650 sprintf(action_name, "ColorProfile%d", i);
2651 action = gtk_action_group_get_action(lw->action_group, action_name);
2653 if (i >= COLOR_PROFILE_FILE)
2655 const gchar *name = options->color_profile.input_name[i - COLOR_PROFILE_FILE];
2656 const gchar *file = options->color_profile.input_file[i - COLOR_PROFILE_FILE];
2660 if (!name || !name[0]) name = filename_from_path(file);
2662 end = layout_color_name_parse(name);
2663 buf = g_strdup_printf(_("Input _%d: %s"), i, end);
2666 g_object_set(G_OBJECT(action), "label", buf, NULL);
2669 gtk_action_set_visible(action, file && file[0]);
2672 gtk_action_set_sensitive(action, !use_image);
2673 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), (i == input));
2676 action = gtk_action_group_get_action(lw->action_group, "Grayscale");
2677 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), layout_image_get_desaturate(lw));
2680 static void layout_util_sync_views(LayoutWindow *lw)
2683 OsdShowFlags osd_flags = image_osd_get(lw->image);
2685 if (!lw->action_group) return;
2687 action = gtk_action_group_get_action(lw->action_group, "FolderTree");
2688 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), lw->options.dir_view_type);
2690 action = gtk_action_group_get_action(lw->action_group, "SplitSingle");
2691 gtk_radio_action_set_current_value(GTK_RADIO_ACTION(action), lw->split_mode);
2693 action = gtk_action_group_get_action(lw->action_group, "SplitNextPane");
2694 gtk_action_set_sensitive(action, !(lw->split_mode == SPLIT_NONE));
2695 action = gtk_action_group_get_action(lw->action_group, "SplitPreviousPane");
2696 gtk_action_set_sensitive(action, !(lw->split_mode == SPLIT_NONE));
2698 action = gtk_action_group_get_action(lw->action_group, "ViewIcons");
2699 gtk_radio_action_set_current_value(GTK_RADIO_ACTION(action), lw->options.file_view_type);
2701 action = gtk_action_group_get_action(lw->action_group, "FloatTools");
2702 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), lw->options.tools_float);
2704 action = gtk_action_group_get_action(lw->action_group, "SBar");
2705 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), layout_bar_enabled(lw));
2707 action = gtk_action_group_get_action(lw->action_group, "SBarSort");
2708 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), layout_bar_sort_enabled(lw));
2710 action = gtk_action_group_get_action(lw->action_group, "HideToolbar");
2711 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), lw->options.toolbar_hidden);
2713 action = gtk_action_group_get_action(lw->action_group, "ShowInfoPixel");
2714 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), lw->options.show_info_pixel);
2716 action = gtk_action_group_get_action(lw->action_group, "ShowMarks");
2717 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), lw->options.show_marks);
2719 action = gtk_action_group_get_action(lw->action_group, "SlideShow");
2720 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), layout_image_slideshow_active(lw));
2722 action = gtk_action_group_get_action(lw->action_group, "Animate");
2723 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), lw->options.animate);
2725 action = gtk_action_group_get_action(lw->action_group, "ImageOverlay");
2726 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), osd_flags != OSD_SHOW_NOTHING);
2728 action = gtk_action_group_get_action(lw->action_group, "ImageHistogram");
2729 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), osd_flags & OSD_SHOW_HISTOGRAM);
2731 action = gtk_action_group_get_action(lw->action_group, "ExifRotate");
2732 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), options->image.exif_rotate_enable);
2734 action = gtk_action_group_get_action(lw->action_group, "RectangularSelection");
2735 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), options->collections.rectangular_selection);
2737 if (osd_flags & OSD_SHOW_HISTOGRAM)
2739 action = gtk_action_group_get_action(lw->action_group, "HistogramChanR");
2740 gtk_radio_action_set_current_value(GTK_RADIO_ACTION(action), image_osd_histogram_get_channel(lw->image));
2742 action = gtk_action_group_get_action(lw->action_group, "HistogramModeLin");
2743 gtk_radio_action_set_current_value(GTK_RADIO_ACTION(action), image_osd_histogram_get_mode(lw->image));
2746 action = gtk_action_group_get_action(lw->action_group, "ConnectZoomMenu");
2747 gtk_action_set_sensitive(action, lw->split_mode != SPLIT_NONE);
2749 action = gtk_action_group_get_action(lw->action_group, "WriteRotation");
2750 gtk_action_set_sensitive(action, !(runcmd("which exiftran >/dev/null") ||
2751 runcmd("which mogrify >/dev/null") || options->metadata.write_orientation));
2752 action = gtk_action_group_get_action(lw->action_group, "WriteRotationKeepDate");
2753 gtk_action_set_sensitive(action, !(runcmd("which exiftran >/dev/null") ||
2754 runcmd("which mogrify >/dev/null") || options->metadata.write_orientation));
2756 action = gtk_action_group_get_action(lw->action_group, "StereoAuto");
2757 gtk_radio_action_set_current_value(GTK_RADIO_ACTION(action), layout_image_stereo_pixbuf_get(lw));
2759 layout_util_sync_color(lw);
2762 void layout_util_sync_thumb(LayoutWindow *lw)
2766 if (!lw->action_group) return;
2768 action = gtk_action_group_get_action(lw->action_group, "Thumbnails");
2769 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), lw->options.show_thumbnails);
2770 g_object_set(action, "sensitive", (lw->options.file_view_type == FILEVIEW_LIST), NULL);
2773 void layout_util_sync(LayoutWindow *lw)
2775 layout_util_sync_views(lw);
2776 layout_util_sync_thumb(lw);
2777 layout_menu_recent_update(lw);
2778 // layout_menu_edit_update(lw);
2783 *-----------------------------------------------------------------------------
2785 *-----------------------------------------------------------------------------
2788 static gboolean layout_bar_enabled(LayoutWindow *lw)
2790 return lw->bar && gtk_widget_get_visible(lw->bar);
2793 static void layout_bar_destroyed(GtkWidget *widget, gpointer data)
2795 LayoutWindow *lw = data;
2799 do not call layout_util_sync_views(lw) here
2800 this is called either when whole layout is destroyed - no need for update
2801 or when the bar is replaced - sync is called by upper function at the end of whole operation
2806 static void layout_bar_set_default(LayoutWindow *lw)
2810 if (!lw->utility_box) return;
2814 layout_bar_set(lw, bar);
2816 bar_populate_default(bar);
2819 static void layout_bar_close(LayoutWindow *lw)
2829 void layout_bar_set(LayoutWindow *lw, GtkWidget *bar)
2831 if (!lw->utility_box) return;
2833 layout_bar_close(lw); /* if any */
2838 g_signal_connect(G_OBJECT(lw->bar), "destroy",
2839 G_CALLBACK(layout_bar_destroyed), lw);
2842 // gtk_box_pack_start(GTK_BOX(lw->utility_box), lw->bar, FALSE, FALSE, 0);
2843 gtk_paned_pack2(GTK_PANED(lw->utility_paned), lw->bar, FALSE, TRUE);
2845 bar_set_fd(lw->bar, layout_image_get_fd(lw));
2849 void layout_bar_toggle(LayoutWindow *lw)
2851 if (layout_bar_enabled(lw))
2853 gtk_widget_hide(lw->bar);
2859 layout_bar_set_default(lw);
2861 gtk_widget_show(lw->bar);
2862 bar_set_fd(lw->bar, layout_image_get_fd(lw));
2864 layout_util_sync_views(lw);
2867 static void layout_bar_new_image(LayoutWindow *lw)
2869 if (!layout_bar_enabled(lw)) return;
2871 bar_set_fd(lw->bar, layout_image_get_fd(lw));
2874 static void layout_bar_new_selection(LayoutWindow *lw, gint count)
2876 if (!layout_bar_enabled(lw)) return;
2878 bar_notify_selection(lw->bar, count);
2881 static gboolean layout_bar_sort_enabled(LayoutWindow *lw)
2883 return lw->bar_sort && gtk_widget_get_visible(lw->bar_sort);
2887 static void layout_bar_sort_destroyed(GtkWidget *widget, gpointer data)
2889 LayoutWindow *lw = data;
2891 lw->bar_sort = NULL;
2894 do not call layout_util_sync_views(lw) here
2895 this is called either when whole layout is destroyed - no need for update
2896 or when the bar is replaced - sync is called by upper function at the end of whole operation
2901 static void layout_bar_sort_set_default(LayoutWindow *lw)
2905 if (!lw->utility_box) return;
2907 bar = bar_sort_new_default(lw);
2909 layout_bar_sort_set(lw, bar);
2912 static void layout_bar_sort_close(LayoutWindow *lw)
2916 bar_sort_close(lw->bar_sort);
2917 lw->bar_sort = NULL;
2921 void layout_bar_sort_set(LayoutWindow *lw, GtkWidget *bar)
2923 if (!lw->utility_box) return;
2925 layout_bar_sort_close(lw); /* if any */
2930 g_signal_connect(G_OBJECT(lw->bar_sort), "destroy",
2931 G_CALLBACK(layout_bar_sort_destroyed), lw);
2933 gtk_box_pack_end(GTK_BOX(lw->utility_box), lw->bar_sort, FALSE, FALSE, 0);
2936 void layout_bar_sort_toggle(LayoutWindow *lw)
2938 if (layout_bar_sort_enabled(lw))
2940 gtk_widget_hide(lw->bar_sort);
2946 layout_bar_sort_set_default(lw);
2948 gtk_widget_show(lw->bar_sort);
2950 layout_util_sync_views(lw);
2953 static void layout_bars_hide_toggle(LayoutWindow *lw)
2955 if (lw->options.bars_state.hidden)
2957 lw->options.bars_state.hidden = FALSE;
2958 if (lw->options.bars_state.sort)
2960 gtk_widget_show(lw->bar_sort);
2962 if (lw->options.bars_state.info)
2964 gtk_widget_show(lw->bar);
2966 layout_tools_float_set(lw, lw->options.tools_float,
2967 lw->options.bars_state.tools_hidden);
2971 lw->options.bars_state.hidden = TRUE;
2972 lw->options.bars_state.sort = layout_bar_sort_enabled(lw);
2973 lw->options.bars_state.info = layout_bar_enabled(lw);
2974 lw->options.bars_state.tools_float = lw->options.tools_float;
2975 lw->options.bars_state.tools_hidden = lw->options.tools_hidden;
2977 gtk_widget_hide(lw->bar);
2979 gtk_widget_hide(lw->bar_sort);
2980 layout_tools_float_set(lw, lw->options.tools_float, TRUE);
2983 layout_util_sync_views(lw);
2986 void layout_bars_new_image(LayoutWindow *lw)
2988 layout_bar_new_image(lw);
2990 if (lw->exif_window) advanced_exif_set_fd(lw->exif_window, layout_image_get_fd(lw));
2992 /* this should be called here to handle the metadata edited in bars */
2993 if (options->metadata.confirm_on_image_change)
2994 metadata_write_queue_confirm(FALSE, NULL, NULL);
2997 void layout_bars_new_selection(LayoutWindow *lw, gint count)
2999 layout_bar_new_selection(lw, count);
3002 GtkWidget *layout_bars_prepare(LayoutWindow *lw, GtkWidget *image)
3004 if (lw->utility_box) return lw->utility_box;
3005 lw->utility_box = gtk_hbox_new(FALSE, PREF_PAD_GAP);
3006 lw->utility_paned = gtk_hpaned_new();
3007 gtk_box_pack_start(GTK_BOX(lw->utility_box), lw->utility_paned, TRUE, TRUE, 0);
3009 gtk_paned_pack1(GTK_PANED(lw->utility_paned), image, TRUE, FALSE);
3010 gtk_widget_show(lw->utility_paned);
3012 gtk_widget_show(image);
3014 g_object_ref(lw->utility_box);
3015 return lw->utility_box;
3018 void layout_bars_close(LayoutWindow *lw)
3020 layout_bar_sort_close(lw);
3021 layout_bar_close(lw);
3024 static void layout_exif_window_destroy(GtkWidget *widget, gpointer data)
3026 LayoutWindow *lw = data;
3027 lw->exif_window = NULL;
3030 void layout_exif_window_new(LayoutWindow *lw)
3032 if (lw->exif_window) return;
3034 lw->exif_window = advanced_exif_new();
3035 if (!lw->exif_window) return;
3036 g_signal_connect(G_OBJECT(lw->exif_window), "destroy",
3037 G_CALLBACK(layout_exif_window_destroy), lw);
3038 advanced_exif_set_fd(lw->exif_window, layout_image_get_fd(lw));
3041 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */