Fix #903, #904: Slideshow settings
[geeqie.git] / src / layout_util.c
index 38b065e..a9c7da7 100644 (file)
@@ -63,7 +63,7 @@
 
 #include <sys/wait.h>
 #include <gdk/gdkkeysyms.h> /* for keyboard values */
-#include "keymap_template.c"
+#include "keymap_template.h"
 
 #define MENU_EDIT_ACTION_OFFSET 16
 #define FILE_COLUMN_POINTER 0
@@ -512,6 +512,15 @@ static void layout_menu_alter_desaturate_cb(GtkToggleAction *action, gpointer da
        layout_image_set_desaturate(lw, gtk_toggle_action_get_active(action));
 }
 
+static void layout_menu_alter_ignore_alpha_cb(GtkToggleAction *action, gpointer data)
+{
+   LayoutWindow *lw = data;
+
+       if (lw->options.ignore_alpha == gtk_toggle_action_get_active(action)) return;
+
+   layout_image_set_ignore_alpha(lw, gtk_toggle_action_get_active(action));
+}
+
 static void layout_menu_alter_none_cb(GtkAction *action, gpointer data)
 {
        LayoutWindow *lw = data;
@@ -532,6 +541,13 @@ static void layout_menu_select_rectangle_cb(GtkToggleAction *action, gpointer da
        options->draw_rectangle = gtk_toggle_action_get_active(action);
 }
 
+static void layout_menu_split_pane_sync_cb(GtkToggleAction *action, gpointer data)
+{
+       LayoutWindow *lw = data;
+
+       lw->options.split_pane_sync = gtk_toggle_action_get_active(action);
+}
+
 static void layout_menu_select_overunderexposed_cb(GtkToggleAction *action, gpointer data)
 {
        LayoutWindow *lw = data;
@@ -586,7 +602,7 @@ static void layout_menu_write_rotate(GtkToggleAction *action, gpointer data, gbo
                        }
 
                rotation = g_strdup_printf("%d", fd_n->user_orientation);
-               command = g_strconcat(GQ_BIN_DIR, "/geeqie-rotate -r ", rotation,
+               command = g_strconcat(gq_bin_dir, "/geeqie-rotate -r ", rotation,
                                                                keep_date ? " -t \"" : " \"", fd_n->path, "\"", NULL);
                cmdstatus = runcmd(command);
                run_result = WEXITSTATUS(cmdstatus);
@@ -645,7 +661,7 @@ static void layout_menu_config_cb(GtkAction *action, gpointer data)
        LayoutWindow *lw = data;
 
        layout_exit_fullscreen(lw);
-       show_config_window();
+       show_config_window(lw);
 }
 
 static void layout_menu_editors_cb(GtkAction *action, gpointer data)
@@ -1527,13 +1543,53 @@ static void layout_menu_image_first_cb(GtkAction *action, gpointer data)
 static void layout_menu_image_prev_cb(GtkAction *action, gpointer data)
 {
        LayoutWindow *lw = data;
-       layout_image_prev(lw);
+       gint i;
+
+       if (lw->options.split_pane_sync)
+               {
+               for (i = 0; i < MAX_SPLIT_IMAGES; i++)
+                       {
+                       if (lw->split_images[i])
+                               {
+                               if (i != -1)
+                                       {
+                                       DEBUG_1("image activate scroll %d", i);
+                                       layout_image_activate(lw, i, FALSE);
+                                       layout_image_prev(lw);
+                                       }
+                               }
+                       }
+               }
+       else
+               {
+               layout_image_prev(lw);
+               }
 }
 
 static void layout_menu_image_next_cb(GtkAction *action, gpointer data)
 {
        LayoutWindow *lw = data;
-       layout_image_next(lw);
+       gint i;
+
+       if (lw->options.split_pane_sync)
+               {
+               for (i = 0; i < MAX_SPLIT_IMAGES; i++)
+                       {
+                       if (lw->split_images[i])
+                               {
+                               if (i != -1)
+                                       {
+                                       DEBUG_1("image activate scroll %d", i);
+                                       layout_image_activate(lw, i, FALSE);
+                                       layout_image_next(lw);
+                                       }
+                               }
+                       }
+               }
+       else
+               {
+               layout_image_next(lw);
+               }
 }
 
 static void layout_menu_page_first_cb(GtkAction *action, gpointer data)
@@ -2011,7 +2067,6 @@ static GList *layout_window_menu_list(GList *listin)
 
 static void layout_menu_new_window_cb(GtkWidget *widget, gpointer data)
 {
-       LayoutWindow *nw = NULL;
        gint n;
 
        n = GPOINTER_TO_INT(data);
@@ -2142,7 +2197,7 @@ static void window_rename_ok_cb(GenericDialog *gd, gpointer data)
        window_rename_ok(gd, rw);
 }
 
-static gboolean window_rename_entry_activate_cb(GenericDialog *gd, gpointer data)
+static void window_rename_entry_activate_cb(GenericDialog *gd, gpointer data)
 {
        RenameWindow *rw = data;
 
@@ -2193,15 +2248,15 @@ static void layout_menu_windows_menu_cb(GtkWidget *widget, gpointer data)
        menu = gtk_ui_manager_get_widget(lw->ui_manager, "/MainMenu/WindowsMenu/");
        sub_menu = gtk_menu_item_get_submenu(GTK_MENU_ITEM(menu));
 
-       /* disable Rename and Delete for main window */
-       if (g_strcmp0(lw->options.id, "main") == 0)
+       /* disable Delete for temporary windows */
+       if (g_str_has_prefix(lw->options.id, "lw"))
                {
                i = 0;
                children = gtk_container_get_children(GTK_CONTAINER(sub_menu));
                for (iter = children; iter != NULL; iter = g_list_next(iter), i++)
                        {
                        menu_label = g_strdup(gtk_menu_item_get_label(GTK_MENU_ITEM(iter->data)));
-                       if (g_strcmp0(menu_label, _("Delete window")) == 0 || g_strcmp0(menu_label, _("Rename window")) == 0)
+                       if (g_strcmp0(menu_label, _("Delete window")) == 0)
                                {
                                gtk_widget_set_sensitive(GTK_WIDGET(iter->data), FALSE);
                                }
@@ -2232,7 +2287,7 @@ static void change_window_id(const gchar *infile, const gchar *outfile)
        out_file_stream = g_file_append_to(out_file, G_FILE_CREATE_PRIVATE, NULL, NULL);
        out_data_stream = g_data_output_stream_new(G_OUTPUT_STREAM(out_file_stream));
 
-       while (line = g_data_input_stream_read_line(in_data_stream, NULL, NULL, NULL))
+       while ((line = g_data_input_stream_read_line(in_data_stream, NULL, NULL, NULL)))
                {
                if (g_str_has_suffix(line, "<layout"))
                        {
@@ -2502,8 +2557,8 @@ static GtkActionEntry menu_entries[] = {
   { "HistogramModeCycle",NULL,                 N_("Cycle through histogram mo_des"),   "J",                    N_("Cycle through histogram modes"),    CB(layout_menu_histogram_toggle_mode_cb) },
   { "HideTools",       PIXBUF_INLINE_ICON_HIDETOOLS,   N_("_Hide file list"),                  "<control>H",           N_("Hide file list"),                   CB(layout_menu_hide_cb) },
   { "SlideShowPause",  GTK_STOCK_MEDIA_PAUSE,  N_("_Pause slideshow"),                 "P",                    N_("Pause slideshow"),                  CB(layout_menu_slideshow_pause_cb) },
-  { "SlideShowFaster", GTK_STOCK_FILE, N_("Faster"),           "<control>KP_Add",                      N_("Slideshow Faster"),                         CB(layout_menu_slideshow_faster_cb) },
-  { "SlideShowSlower", GTK_STOCK_FILE, N_("Slower"),           "<control>KP_Subtract",                 N_("Slideshow Slower"),                         CB(layout_menu_slideshow_slower_cb) },
+  { "SlideShowFaster", GTK_STOCK_FILE, N_("Faster"),           "<control>equal",                       N_("Slideshow Faster"),                         CB(layout_menu_slideshow_faster_cb) },
+  { "SlideShowSlower", GTK_STOCK_FILE, N_("Slower"),           "<control>minus",                       N_("Slideshow Slower"),                         CB(layout_menu_slideshow_slower_cb) },
   { "Refresh",         GTK_STOCK_REFRESH,      N_("_Refresh"),                         "R",                    N_("Refresh"),                          CB(layout_menu_refresh_cb) },
   { "HelpContents",    GTK_STOCK_HELP,         N_("_Contents"),                        "F1",                   N_("Contents"),                         CB(layout_menu_help_cb) },
   { "HelpSearch",      NULL,           N_("On-line help search"),                      NULL,                   N_("On-line help search"),                              CB(layout_menu_help_search_cb) },
@@ -2530,6 +2585,7 @@ static GtkToggleActionEntry menu_toggle_entries[] = {
   { "ShowMarks",        PIXBUF_INLINE_ICON_MARKS,      N_("Show _Marks"),                      "M",                    N_("Show Marks"),                       CB(layout_menu_marks_cb),        FALSE  },
   { "ShowFileFilter", PIXBUF_INLINE_ICON_FILE_FILTER,  N_("Show File Filter"), NULL,   N_("Show File Filter"), CB(layout_menu_file_filter_cb),  FALSE  },
   { "ShowInfoPixel",   GTK_STOCK_COLOR_PICKER, N_("Pi_xel Info"),                      NULL,                   N_("Show Pixel Info"),                  CB(layout_menu_info_pixel_cb),   FALSE  },
+  { "IgnoreAlpha", GTK_STOCK_STRIKETHROUGH,           N_("Hide _alpha"),          "<shift>A",     N_("Hide alpha channel"),       CB(layout_menu_alter_ignore_alpha_cb), FALSE},
   { "FloatTools",      PIXBUF_INLINE_ICON_FLOAT,N_("_Float file list"),                "L",                    N_("Float file list"),                  CB(layout_menu_float_cb),        FALSE  },
   { "HideToolbar",     NULL,                   N_("Hide tool_bar"),                    NULL,                   N_("Hide toolbar"),                     CB(layout_menu_toolbar_cb),      FALSE  },
   { "SBar",    PIXBUF_INLINE_ICON_INFO,        N_("_Info sidebar"),                    "<control>K",           N_("Info sidebar"),                     CB(layout_menu_bar_cb),          FALSE  },
@@ -2547,6 +2603,7 @@ static GtkToggleActionEntry menu_toggle_entries[] = {
   { "ExifRotate",      GTK_STOCK_ORIENTATION_PORTRAIT,                 N_("_Exif rotate"),             "<alt>X",               N_("Exif rotate"),                      CB(layout_menu_exif_rotate_cb), FALSE },
   { "DrawRectangle",   PIXBUF_INLINE_ICON_DRAW_RECTANGLE,                      N_("Draw Rectangle"),           NULL,           N_("Draw Rectangle"),                   CB(layout_menu_select_rectangle_cb), FALSE },
   { "OverUnderExposed",        PIXBUF_INLINE_ICON_EXPOSURE,    N_("Over/Under Exposed"),       "<shift>E",             N_("Over/Under Exposed"),               CB(layout_menu_select_overunderexposed_cb), FALSE },
+  { "SplitPaneSync",   PIXBUF_INLINE_SPLIT_PANE_SYNC,                  N_("Split Pane Sync"),  NULL,           N_("Split Pane Sync"),  CB(layout_menu_split_pane_sync_cb), FALSE },
 };
 
 static GtkRadioActionEntry menu_radio_entries[] = {
@@ -2767,6 +2824,8 @@ static const gchar *menu_ui_description =
 "        <menuitem action='SplitPreviousPane'/>"
 "        <menuitem action='SplitUpPane'/>"
 "        <menuitem action='SplitDownPane'/>"
+"        <separator/>"
+"        <menuitem action='SplitPaneSync'/>"
 "      </menu>"
 "      <menu action='StereoMenu'>"
 "        <menuitem action='StereoAuto'/>"
@@ -2813,6 +2872,7 @@ static const gchar *menu_ui_description =
 "      <menuitem action='SBarSort'/>"
 "      <menuitem action='HideBars'/>"
 "      <menuitem action='ShowInfoPixel'/>"
+"      <menuitem action='IgnoreAlpha'/>"
 "      <placeholder name='ToolsSection'/>"
 "      <separator/>"
 "      <menuitem action='Animate'/>"
@@ -3587,9 +3647,10 @@ void layout_util_sync_color(LayoutWindow *lw)
        gboolean use_image = FALSE;
        gint i;
        gchar action_name[15];
+#ifdef HAVE_LCMS
        gchar *image_profile;
        gchar *screen_profile;
-
+#endif
 
        if (!lw->action_group) return;
        if (!layout_image_color_profile_get(lw, &input, &use_image)) return;
@@ -3696,6 +3757,9 @@ static void layout_util_sync_views(LayoutWindow *lw)
        action = gtk_action_group_get_action(lw->action_group, "SplitDownPane");
        gtk_action_set_sensitive(action, !(lw->split_mode == SPLIT_NONE));
 
+       action = gtk_action_group_get_action(lw->action_group, "SplitPaneSync");
+       gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), lw->options.split_pane_sync);
+
        action = gtk_action_group_get_action(lw->action_group, "ViewIcons");
        gtk_radio_action_set_current_value(GTK_RADIO_ACTION(action), lw->options.file_view_type);
 
@@ -3717,6 +3781,9 @@ static void layout_util_sync_views(LayoutWindow *lw)
        action = gtk_action_group_get_action(lw->action_group, "SlideShow");
        gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), layout_image_slideshow_active(lw));
 
+       action = gtk_action_group_get_action(lw->action_group, "IgnoreAlpha");
+       gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), lw->options.ignore_alpha);
+
        action = gtk_action_group_get_action(lw->action_group, "Animate");
        gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), lw->options.animate);
 
@@ -3771,6 +3838,7 @@ static void layout_util_sync_views(LayoutWindow *lw)
 
        layout_util_sync_marks(lw);
        layout_util_sync_color(lw);
+       layout_image_set_ignore_alpha(lw, lw->options.ignore_alpha);
 }
 
 void layout_util_sync_thumb(LayoutWindow *lw)