Return summaryview cursor to selected mail when popup menu is done
authorAndrej Kacian <ticho@claws-mail.org>
Tue, 14 May 2019 21:20:08 +0000 (23:20 +0200)
committerAndrej Kacian <ticho@claws-mail.org>
Tue, 14 May 2019 21:21:09 +0000 (23:21 +0200)
Fixes bug #3838: Canceled right-click on message
list leaves UI in inconsistent state

src/summaryview.c

index d03d1b7..40d5514 100644 (file)
@@ -532,6 +532,19 @@ GtkWidget *summary_get_main_widget(SummaryView *summaryview)
                summary_update_msg, (gpointer) summaryview);    \
 }
 
+static void popup_menu_selection_done(GtkMenuShell *shell, gpointer user_data)
+{
+       SummaryView *summaryview = (SummaryView *)user_data;
+
+       cm_return_if_fail(summaryview != NULL);
+
+       /* If a message is displayed, place cursor back on the message. */
+       if (summaryview->displayed != NULL &&
+                       summaryview->displayed != summaryview->selected) {
+               gtk_sctree_select(GTK_SCTREE(summaryview->ctree), summaryview->displayed);
+       }
+}
+
 SummaryView *summary_create(MainWindow *mainwin)
 {
        SummaryView *summaryview;
@@ -2772,6 +2785,8 @@ static void summary_status_show(SummaryView *summaryview)
                                              n_new, n_unread, n_total,
                                              to_human_readable((goffset)n_size));
 
+       g_signal_connect(G_OBJECT(summaryview->popupmenu), "selection-done",
+                       G_CALLBACK(popup_menu_selection_done), summaryview);
 
                gtk_label_set_text(GTK_LABEL(summaryview->statlabel_msgs), str);
                g_free(str);