avoid unwanted summaryview refresh...
authorPaul <paul@claws-mail.org>
Mon, 25 Nov 2019 12:52:44 +0000 (12:52 +0000)
committerPaul <paul@claws-mail.org>
Mon, 25 Nov 2019 12:52:44 +0000 (12:52 +0000)
... such as when modifying a msg by Actions
Should also fix bug 4277, 'INBOX being "read" automatically - being
marked as read before being selected'

12 files changed:
src/action.c
src/folderview.c
src/imap_gtk.c
src/mainwindow.c
src/mh_gtk.c
src/news_gtk.c
src/plugins/mailmbox/plugin_gtk.c
src/plugins/vcalendar/vcal_meeting_gtk.c
src/plugins/vcalendar/vcalendar.c
src/prefs_folder_item.c
src/summaryview.c
src/summaryview.h

index b975f8e..716f2e4 100644 (file)
@@ -753,7 +753,7 @@ static gboolean execute_filtering_actions(gchar *action, GSList *msglist)
                summary_thaw(summaryview);              
                main_window_cursor_normal(mainwin);     
                summary_unlock(summaryview);                            
-               summary_show(summaryview, summaryview->folder_item);
+               summary_show(summaryview, summaryview->folder_item, FALSE);
        }
        for (p = action_list; p; p = g_slist_next(p))
                if (p->data) filteringaction_free(p->data);     
@@ -1481,7 +1481,7 @@ static void catch_status(GPid pid, gint status, gpointer data)
                }
                if (modified_something && last_item && 
                    summaryview && summaryview->folder_item == last_item) {
-                       summary_show (summaryview, summaryview->folder_item);
+                       summary_show (summaryview, summaryview->folder_item, FALSE);
                }
                g_slist_free (child_info->msginfo_list);
                child_info->msginfo_list = NULL;
index 86ec4be..35f72da 100644 (file)
@@ -1802,7 +1802,7 @@ static gboolean folderview_update_item_claws(gpointer source, gpointer data)
                     update_info->item == folderview->summaryview->folder_item &&
                     update_info->item != NULL)
                        if (!quicksearch_has_sat_predicate(folderview->summaryview->quicksearch))
-                               summary_show(folderview->summaryview, update_info->item);
+                               summary_show(folderview->summaryview, update_info->item, FALSE);
        }
        
        return FALSE;
@@ -2235,7 +2235,7 @@ void folderview_close_opened(FolderView *folderview, gboolean dirty)
                        main_window_cursor_wait(folderview->mainwin);
                        g_free(buf);
                        summary_save_prefs_to_folderitem(folderview->summaryview, olditem);
-                       summary_show(folderview->summaryview, NULL);
+                       summary_show(folderview->summaryview, NULL, FALSE);
                        folder_item_close(olditem);
                        main_window_cursor_normal(folderview->mainwin);
                        STATUSBAR_POP(folderview->mainwin);
@@ -2368,7 +2368,7 @@ static void folderview_selected(GtkCMCTree *ctree, GtkCMCTreeNode *row,
 
        /* Show messages */
        summary_set_prefs_from_folderitem(folderview->summaryview, item);
-       opened = summary_show(folderview->summaryview, item);
+       opened = summary_show(folderview->summaryview, item, FALSE);
        
        folder_clean_cache_memory(item);
 
index e7b4a20..afc5a5e 100644 (file)
@@ -404,7 +404,7 @@ static void update_tree_cb(GtkAction *action, gpointer data)
        item = folderview_get_selected_item(folderview);
        cm_return_if_fail(item != NULL);
 
-       summary_show(folderview->summaryview, NULL);
+       summary_show(folderview->summaryview, NULL, FALSE);
 
        cm_return_if_fail(item->folder != NULL);
 
index 62eea35..af1b275 100644 (file)
@@ -2797,7 +2797,7 @@ void main_window_toggle_message_view(MainWindow *mainwin)
        }
        summary_grab_focus(summaryview);
        if (!summary_is_list(summaryview)) {
-               summary_show(summaryview, summaryview->folder_item);
+               summary_show(summaryview, summaryview->folder_item, FALSE);
        }
 }
 
@@ -3980,7 +3980,7 @@ static void add_mailbox_cb(GtkAction *action, gpointer data)
 static void update_folderview_cb(GtkAction *action, gpointer data)
 {
        MainWindow *mainwin = (MainWindow *)data;
-       summary_show(mainwin->summaryview, NULL);
+       summary_show(mainwin->summaryview, NULL, FALSE);
        folderview_check_new_all();
 }
 
@@ -4668,7 +4668,7 @@ static void thread_cb(GtkAction *action, gpointer data)
        mainwin->summaryview->threaded = threaded;
 
        summary_show(mainwin->summaryview, 
-                       mainwin->summaryview->folder_item);
+                       mainwin->summaryview->folder_item, FALSE);
        summary_select_by_msgnum(mainwin->summaryview, selected_msgnum, FALSE);
 }
 
@@ -4860,7 +4860,7 @@ static void update_summary_cb(GtkAction *action, gpointer data)
 
        folder_update_op_count();
        folder_item_scan(fitem);
-       summary_show(mainwin->summaryview, fitem);
+       summary_show(mainwin->summaryview, fitem, FALSE);
 }
 
 static void prev_cb(GtkAction *action, gpointer data)
index b1a1623..2188472 100644 (file)
@@ -345,7 +345,7 @@ static void update_tree_cb(GtkAction *action, gpointer data)
        item = folderview_get_selected_item(folderview);
        cm_return_if_fail(item != NULL);
 
-       summary_show(folderview->summaryview, NULL);
+       summary_show(folderview->summaryview, NULL, FALSE);
 
        cm_return_if_fail(item->folder != NULL);
 
index 15e1804..e008219 100644 (file)
@@ -329,7 +329,7 @@ static void update_tree_cb(GtkAction *action, gpointer data)
        if (mainwin->lock_count || news_folder_locked(item->folder))
                return;
 
-       summary_show(folderview->summaryview, NULL);
+       summary_show(folderview->summaryview, NULL, FALSE);
 
        cm_return_if_fail(item->folder != NULL);
 
index 166055c..abe8988 100644 (file)
@@ -171,7 +171,7 @@ static void update_tree_cb(GtkAction *action, gpointer data)
        item = folderview_get_selected_item(folderview);
        g_return_if_fail(item != NULL);
 
-       summary_show(folderview->summaryview, NULL);
+       summary_show(folderview->summaryview, NULL, FALSE);
 
        g_return_if_fail(item->folder != NULL);
 
@@ -347,7 +347,7 @@ static void delete_folder_cb(GtkAction *action, gpointer data)
                alertpanel_error(_("Can't remove the folder '%s'."), name);
                if (item == opened)
                        summary_show(folderview->summaryview,
-                                    folderview->summaryview->folder_item);
+                                    folderview->summaryview->folder_item, FALSE);
                g_free(old_id);
                return;
        }
index a08c45a..2c010cf 100644 (file)
@@ -1190,7 +1190,7 @@ static gboolean send_meeting_cb(GtkButton *widget, gpointer data)
                MainWindow *mainwin = mainwindow_get_mainwindow();
                if (mainwin->summaryview->folder_item == folder->inbox) {
                        redisp = TRUE;
-                       summary_show(mainwin->summaryview, NULL);
+                       summary_show(mainwin->summaryview, NULL, FALSE);
                }
        }
        gtk_widget_set_sensitive(meet->save_btn, FALSE);
@@ -1301,7 +1301,7 @@ static gboolean send_meeting_cb(GtkButton *widget, gpointer data)
 
        if (folder && redisp) {
                MainWindow *mainwin = mainwindow_get_mainwindow();
-               summary_show(mainwin->summaryview, folder->inbox);
+               summary_show(mainwin->summaryview, folder->inbox, FALSE);
        }
 
        return res;
index fe604ef..81a2299 100644 (file)
@@ -930,7 +930,7 @@ void vcalendar_refresh_folder_contents(FolderItem *item)
                MainWindow *mainwin = mainwindow_get_mainwindow();
                folder_item_scan(item);
                if (mainwin->summaryview->folder_item == item) {
-                       summary_show(mainwin->summaryview, item);
+                       summary_show(mainwin->summaryview, item, FALSE);
                }
        }
 }
@@ -974,7 +974,7 @@ void vcalendar_cancel_meeting(FolderItem *item, const gchar *uid)
                MainWindow *mainwin = mainwindow_get_mainwindow();
                if (mainwin->summaryview->folder_item == item) {
                        redisp = TRUE;
-                       summary_show(mainwin->summaryview, NULL);
+                       summary_show(mainwin->summaryview, NULL, FALSE);
                }
        }
        
@@ -989,7 +989,7 @@ void vcalendar_cancel_meeting(FolderItem *item, const gchar *uid)
 
                        if (folder && redisp) {
                                MainWindow *mainwin = mainwindow_get_mainwindow();
-                               summary_show(mainwin->summaryview, item);
+                               summary_show(mainwin->summaryview, item, FALSE);
                        }
                        return;
                }
@@ -1005,7 +1005,7 @@ void vcalendar_cancel_meeting(FolderItem *item, const gchar *uid)
                folder_item_scan(item);
        if (folder && redisp) {
                MainWindow *mainwin = mainwindow_get_mainwindow();
-               summary_show(mainwin->summaryview, item);
+               summary_show(mainwin->summaryview, item, FALSE);
        }
 
        return;
index 1c315b2..fc2e1af 100644 (file)
@@ -756,7 +756,7 @@ static void general_save_folder_prefs(FolderItem *folder, FolderItemGeneralPage
 
        if (folder->opened && summary_update_needed) {
                summary_set_prefs_from_folderitem(folderview->summaryview, folder);
-               summary_show(folderview->summaryview, folder);
+               summary_show(folderview->summaryview, folder, FALSE);
        }       
 }      
 
index c124169..370d7a9 100644 (file)
@@ -1272,7 +1272,7 @@ gboolean summaryview_search_root_progress(gpointer data, guint at, guint matched
        return TRUE;
 }
 
-gboolean summary_show(SummaryView *summaryview, FolderItem *item)
+gboolean summary_show(SummaryView *summaryview, FolderItem *item, gboolean avoid_refresh)
 {
        GtkCMCTree *ctree = GTK_CMCTREE(summaryview->ctree);
        GtkCMCTreeNode *node = NULL;
@@ -1299,7 +1299,7 @@ gboolean summary_show(SummaryView *summaryview, FolderItem *item)
        
        utils_free_regex();
 
-       is_refresh = (item == summaryview->folder_item) ? TRUE : FALSE;
+       is_refresh = (item == summaryview->folder_item && !manual_filtering) ? TRUE : FALSE;
 
        if (item && item->folder->klass->item_opened) {
                item->folder->klass->item_opened(item);
@@ -1431,7 +1431,7 @@ gboolean summary_show(SummaryView *summaryview, FolderItem *item)
                        main_window_cursor_normal(summaryview->mainwin);
                        summary_unlock(summaryview);
                        inc_unlock();
-                       summary_show(summaryview, summaryview->folder_item);
+                       summary_show(summaryview, summaryview->folder_item, FALSE);
                        END_TIMING();
                        return FALSE;
                }
@@ -1514,43 +1514,52 @@ gboolean summary_show(SummaryView *summaryview, FolderItem *item)
 
        g_slist_free(mlist);
 
-       if (quicksearch_is_in_typing(summaryview->quicksearch) ||
-           quicksearch_is_running(summaryview->quicksearch)) {
-               summaryview->displayed =
-                       summary_find_msg_by_msgnum(summaryview,
-                                                  displayed_msgnum);
-               if (!summaryview->displayed)
-                       messageview_clear(summaryview->messageview);
-               summary_unlock(summaryview);
-
-               if (quicksearch_is_running(summaryview->quicksearch))
-                       summary_select_by_msgnum(summaryview, selected_msgnum,
-                                       OPEN_SELECTED_ON_SEARCH_RESULTS);
-               else
-                       summary_select_by_msgnum(summaryview, selected_msgnum,
-                                       FALSE);
-
-               summary_lock(summaryview);
-               if (!summaryview->selected) {
-                       /* no selected message - select first unread
-                          message, but do not display it */
-                       node = summary_find_next_flagged_msg(summaryview, NULL,
-                                                            MSG_UNREAD, FALSE);
-                       if (node == NULL && GTK_CMCLIST(ctree)->row_list != NULL)
-                               node = gtk_cmctree_node_nth
-                                       (ctree,
-                                        item->sort_type == SORT_DESCENDING
-                                        ? 0 : GTK_CMCLIST(ctree)->rows - 1);
+       if (is_refresh) {
+               if (!quicksearch_is_in_typing(summaryview->quicksearch)) {
+                       summaryview->displayed =
+                               summary_find_msg_by_msgnum(summaryview,
+                                                          displayed_msgnum);
+                       if (!summaryview->displayed)
+                               messageview_clear(summaryview->messageview);
                        summary_unlock(summaryview);
 
                        if (quicksearch_is_running(summaryview->quicksearch))
-                               summary_select_node(summaryview, node,
+                               summary_select_by_msgnum(summaryview, selected_msgnum,
                                                OPEN_SELECTED_ON_SEARCH_RESULTS);
                        else
-                               summary_select_node(summaryview, node,
-                                               OPEN_SELECTED_ON_FOLDER_OPEN);
+                               summary_select_by_msgnum(summaryview, selected_msgnum,
+                                               FALSE);
 
                        summary_lock(summaryview);
+                       if (!summaryview->selected) {
+                               /* no selected message - select first unread
+                                  message, but do not display it */
+                               node = summary_find_next_flagged_msg(summaryview, NULL,
+                                                                    MSG_UNREAD, FALSE);
+                               if (node == NULL && GTK_CMCLIST(ctree)->row_list != NULL)
+                                       node = gtk_cmctree_node_nth
+                                               (ctree,
+                                                item->sort_type == SORT_DESCENDING
+                                                ? 0 : GTK_CMCLIST(ctree)->rows - 1);
+                               summary_unlock(summaryview);
+
+                               if (quicksearch_is_running(summaryview->quicksearch))
+                                       summary_select_node(summaryview, node,
+                                                       OPEN_SELECTED_ON_SEARCH_RESULTS);
+                               else
+                                       summary_select_node(summaryview, node,
+                                                       OPEN_SELECTED_ON_FOLDER_OPEN);
+
+                               summary_lock(summaryview);
+                       }
+               } else {
+                       /* just select first/last */
+                       if (GTK_CMCLIST(ctree)->row_list != NULL)
+                               node = gtk_cmctree_node_nth
+                                       (ctree,
+                                        item->sort_type == SORT_DESCENDING
+                                        ? 0 : GTK_CMCLIST(ctree)->rows - 1);
+                       summary_select_node(summaryview, node, OPEN_SELECTED_ON_SEARCH_RESULTS);
                }
        } else {
                /* backward compat */
@@ -1656,10 +1665,12 @@ gboolean summary_show(SummaryView *summaryview, FolderItem *item)
 
                if (node) {
                        gint open_selected = -1;
-                       if (OPEN_SELECTED_ON_FOLDER_OPEN)
-                               open_selected = 1;
-                       else
-                               open_selected = 0;
+                       if (!is_refresh) {
+                               if (OPEN_SELECTED_ON_FOLDER_OPEN)
+                                       open_selected = 1;
+                               else
+                                       open_selected = 0;
+                       }
                        summary_select_node(summaryview, node, open_selected);
                }
 
@@ -3010,7 +3021,7 @@ void summary_reflect_prefs(void)
        summary_relayout(summaryview);
        
        if (summaryview->folder_item)
-               summary_show(summaryview, summaryview->folder_item);
+               summary_show(summaryview, summaryview->folder_item, FALSE);
 }
 
 void summary_sort(SummaryView *summaryview,
@@ -5212,7 +5223,7 @@ gboolean summary_execute(SummaryView *summaryview)
        main_window_cursor_normal(summaryview->mainwin);
 
        if (move_val < 0) 
-               summary_show(summaryview, summaryview->folder_item);
+               summary_show(summaryview, summaryview->folder_item, FALSE);
        return TRUE;
 }
 
@@ -5900,7 +5911,7 @@ void summary_filter(SummaryView *summaryview, gboolean selected_only)
         * CLAWS: summary_show() only valid after having a lock. ideally
         * we want the lock to be context aware...  
         */
-       summary_show(summaryview, summaryview->folder_item);
+       summary_show(summaryview, summaryview->folder_item, TRUE);
 }
 
 static void summary_filter_func(MsgInfo *msginfo, PrefsAccount *ac_prefs)
@@ -6883,7 +6894,7 @@ void summary_set_column_order(SummaryView *summaryview)
        gtk_container_add(GTK_CONTAINER(scrolledwin), ctree);
        gtk_widget_show(ctree);
 
-       summary_show(summaryview, item);
+       summary_show(summaryview, item, FALSE);
 
        summary_select_by_msgnum(summaryview, selected_msgnum, FALSE);
 
@@ -7143,7 +7154,7 @@ static void quicksearch_execute_cb(QuickSearch *quicksearch, gpointer data)
        SummaryView *summaryview = data;
 
        summaryview_reset_recursive_folder_match(summaryview);
-       if (summary_show(summaryview, summaryview->folder_item))
+       if (summary_show(summaryview, summaryview->folder_item, FALSE))
                summaryview_quicksearch_recurse(summaryview);
        else
                summaryview_reset_recursive_folder_match(summaryview);
@@ -8135,7 +8146,7 @@ void summary_toggle_show_read_messages(SummaryView *summaryview)
        source.update_flags = F_ITEM_UPDATE_NAME;
        source.msg = NULL;
        hooks_invoke(FOLDER_ITEM_UPDATE_HOOKLIST, &source);
-       summary_show(summaryview, summaryview->folder_item);
+       summary_show(summaryview, summaryview->folder_item, FALSE);
 }
  
 void summary_toggle_show_del_messages(SummaryView *summaryview)
@@ -8150,7 +8161,7 @@ void summary_toggle_show_del_messages(SummaryView *summaryview)
        source.update_flags = F_ITEM_UPDATE_NAME;
        source.msg = NULL;
        hooks_invoke(FOLDER_ITEM_UPDATE_HOOKLIST, &source);
-       summary_show(summaryview, summaryview->folder_item);
+       summary_show(summaryview, summaryview->folder_item, FALSE);
 }
  
 void summary_toggle_show_read_threads(SummaryView *summaryview)
@@ -8165,7 +8176,7 @@ void summary_toggle_show_read_threads(SummaryView *summaryview)
        source.update_flags = F_ITEM_UPDATE_NAME;
        source.msg = NULL;
        hooks_invoke(FOLDER_ITEM_UPDATE_HOOKLIST, &source);
-       summary_show(summaryview, summaryview->folder_item);
+       summary_show(summaryview, summaryview->folder_item, FALSE);
 }
  
 static void summary_set_hide_menu (SummaryView *summaryview,
index c90a48b..660572f 100644 (file)
@@ -188,7 +188,8 @@ SummaryView *summary_create(MainWindow *mainwin);
 void summaryview_destroy(SummaryView *summaryview);
 void summary_init                (SummaryView          *summaryview);
 gboolean summary_show            (SummaryView          *summaryview,
-                                  FolderItem           *fitem);
+                                  FolderItem           *fitem,
+                                  gboolean              avoid_refresh);
 void summary_clear_list                  (SummaryView          *summaryview);
 void summary_clear_all           (SummaryView          *summaryview);