Fix summary_select_all when there is nothing selected.
authorAndrej Kacian <ticho@claws-mail.org>
Mon, 26 Feb 2018 21:06:27 +0000 (22:06 +0100)
committerAndrej Kacian <ticho@claws-mail.org>
Mon, 26 Feb 2018 21:09:51 +0000 (22:09 +0100)
Due to how GtkCMCList works, we first need to focus and
select a row.
Fixes bug #3973, ''select all' in summaryview does not
automatically focus the summaryview'

src/summaryview.c

index 60938efc35f43a81e695304b7e1176605c7773f6..586d7b1c23e3e59200e075c7b80293db05772f4e 100644 (file)
@@ -4819,11 +4819,26 @@ void summary_add_address(SummaryView *summaryview)
 
 void summary_select_all(SummaryView *summaryview)
 {
+       GtkCMCTreeNode *node;
+
        if (!summaryview->folder_item) return;
 
+       if (GTK_CMCLIST(summaryview->ctree)->focus_row < 0) {
+               /* If no row is selected, select (but do not open) the first
+                * row, to get summaryview into correct state for selecting all. */
+               debug_print("summary_select_all: no row selected, selecting first one\n");
+               if (GTK_CMCLIST(summaryview->ctree)->row_list != NULL) {
+                       node = gtk_cmctree_node_nth(GTK_CMCTREE(summaryview->ctree), 0);
+                       summary_select_node(summaryview, node, FALSE);
+               }
+       }
+
+       /* Now select all rows while locking the summaryview for
+        * faster performance. */
        summary_lock(summaryview);
        gtk_cmclist_select_all(GTK_CMCLIST(summaryview->ctree));
        summary_unlock(summaryview);
+
        summary_status_show(summaryview);
 }