Add open_selected_on_folder_open to common prefs.
authorAndrej Kacian <ticho@claws-mail.org>
Thu, 10 Nov 2016 19:34:17 +0000 (20:34 +0100)
committerAndrej Kacian <ticho@claws-mail.org>
Fri, 11 Nov 2016 16:31:09 +0000 (17:31 +0100)
This option overrides always_show_message_when_selected
option when selecting initial message during folder open.

This is useful so that the message's unread flag doesn't
get unset before user had the chance of noticing it, or
that an overly large message doesn't get automatically
selected if user doesn't want it (e.g. IMAP over a slow
connection).

src/prefs_common.c
src/prefs_common.h
src/prefs_summaries.c
src/prefs_summary_open.c
src/summaryview.c

index feeb956..bf273a9 100644 (file)
@@ -786,6 +786,9 @@ static PrefParam param[] = {
 #endif
        /* {"emulate_emacs", "FALSE", &prefs_common.emulate_emacs, P_BOOL,
         NULL, NULL, NULL}, */
+       {"open_selected_message_on_folder_open", "FALSE",
+        &prefs_common.open_selected_on_folder_open,
+        P_BOOL, NULL, NULL, NULL},
        {"always_show_message_when_selected", "0",
         &prefs_common.always_show_msg,
         P_ENUM, NULL, NULL, NULL},
index 2c56b4d..533c0dd 100644 (file)
@@ -92,8 +92,8 @@ typedef enum
 
 typedef enum
 {
-       OPENMSG_REQUEST_ONLY = 0,
-       OPENMSG_ALWAYS = 1,
+       OPENMSG_NO = 0,
+       OPENMSG_YES = 1,
        OPENMSG_WHEN_VIEW_VISIBLE
 } ShowMsgPolicy;
 
@@ -368,6 +368,7 @@ struct _PrefsCommon
 
        gint statusbar_update_step;
        gboolean emulate_emacs;
+       gboolean open_selected_on_folder_open;
        ShowMsgPolicy always_show_msg;
        gboolean mark_as_read_on_new_window;
        gboolean mark_as_read_delay;
index 8cce007..3b2b3a2 100644 (file)
@@ -501,9 +501,9 @@ static void prefs_summaries_create_widget(PrefsPage *_page, GtkWindow *window,
        menu = GTK_LIST_STORE(gtk_combo_box_get_model(
                                GTK_COMBO_BOX(optmenu_always_show_msg)));
        gtk_widget_show (optmenu_always_show_msg);
-       COMBOBOX_ADD (menu, _("Never"), OPENMSG_REQUEST_ONLY);
-       COMBOBOX_ADD (menu, _("Always"), OPENMSG_ALWAYS);
-       COMBOBOX_ADD (menu, _("When message view is visible"),
+       COMBOBOX_ADD (menu, _("No"), OPENMSG_NO);
+       COMBOBOX_ADD (menu, _("Yes"), OPENMSG_YES);
+       COMBOBOX_ADD (menu, _("Only when message view is visible"),
                        OPENMSG_WHEN_VIEW_VISIBLE);
        gtk_box_pack_start(GTK_BOX(hbox1), optmenu_always_show_msg, FALSE, FALSE, 0);
 
index 37db95a..b1c235d 100644 (file)
@@ -56,6 +56,8 @@ static struct SummaryOpen {
 
        GtkWidget *possible_actions_list_view;
        GtkWidget *actions_list_view;
+
+       GtkWidget *open_on_select;
 } summaryopen;
 
 /* widget creating functions */
@@ -159,6 +161,7 @@ static void prefs_summary_open_create(void)
        GtkWidget *list_view_scrolledwin;
        GtkWidget *possible_actions_list_view;
        GtkWidget *actions_list_view;
+       GtkWidget *checkbtn_open_on_select;
        
        window = gtkut_window_new(GTK_WINDOW_TOPLEVEL, "prefs_summary_open");
        gtk_container_set_border_width (GTK_CONTAINER (window), 8);
@@ -295,7 +298,9 @@ static void prefs_summary_open_create(void)
        gtk_box_pack_start (GTK_BOX (btn_vbox), down_btn, FALSE, FALSE, 0);
        g_signal_connect (G_OBJECT (down_btn), "clicked",
                          G_CALLBACK (prefs_summary_open_down), NULL);
-       
+
+       PACK_CHECK_BUTTON(vbox, checkbtn_open_on_select,
+                       _("Open the selected message"));
 
        gtk_widget_show_all(window);
 
@@ -305,6 +310,7 @@ static void prefs_summary_open_create(void)
 
        summaryopen.possible_actions_list_view        = possible_actions_list_view;
        summaryopen.actions_list_view = actions_list_view;
+       summaryopen.open_on_select = checkbtn_open_on_select;
 }
 
 /* do it SUMMARY_OPEN_ACTIONS-1 times */
@@ -380,6 +386,10 @@ fill:
                                        (model_poss), action_name[i], i);       
                }
        }
+
+       gtk_toggle_button_set_active
+               (GTK_TOGGLE_BUTTON(summaryopen.open_on_select),
+                prefs_common.open_selected_on_folder_open);
 }
 
 static void prefs_summary_open_set_list(void)
@@ -543,6 +553,10 @@ static void prefs_summary_open_ok(void)
        for (i = 0; i < SUMMARY_OPEN_ACTIONS-1; i++)
                saved_summary_select_prio[i] = prefs_common.summary_select_prio[i];
 
+       prefs_common.open_selected_on_folder_open =
+               gtk_toggle_button_get_active
+               (GTK_TOGGLE_BUTTON(summaryopen.open_on_select));
+
        gtk_widget_hide(summaryopen.window);
        gtk_window_set_modal(GTK_WINDOW(summaryopen.window), FALSE);
 }
index 67578cc..a58fa90 100644 (file)
@@ -1550,8 +1550,18 @@ gboolean summary_show(SummaryView *summaryview, FolderItem *item)
                }
 
                summary_unlock(summaryview);
-               if (node)
-                       summary_select_node(summaryview, node, -1);
+
+               if (node) {
+                       gint open_selected = -1;
+                       if (!is_refresh) {
+                               if (prefs_common.open_selected_on_folder_open)
+                                       open_selected = 1;
+                               else
+                                       open_selected = 0;
+                       }
+                       summary_select_node(summaryview, node, open_selected);
+               }
+
                summary_lock(summaryview);
        }
 
@@ -2230,7 +2240,7 @@ void summary_select_node(SummaryView *summaryview, GtkCMCTreeNode *node,
        gboolean display_msg;
        
        display_msg = force_display > -1? force_display :
-               (prefs_common.always_show_msg == OPENMSG_ALWAYS) ||
+               (prefs_common.always_show_msg == OPENMSG_YES) ||
                ((prefs_common.always_show_msg == OPENMSG_WHEN_VIEW_VISIBLE &&
                                messageview_is_visible(summaryview->messageview)));