[balsa] Various: Restore filtering in unopened mailbox



commit af2ec3b7e7e262272ed3268fa7ac04356c449db9
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Tue Jun 9 11:38:18 2020 -0400

    Various: Restore filtering in unopened mailbox
    
    Restore filtering in a mailbox that is not currently being viewed.
    
    * libbalsa/mailbox.c (libbalsa_mailbox_message_match), (lbm_cache_message):
      make sure we cache message info when we need it for matching;
    * libbalsa/mailbox_local.c (message_match_real): guard against NULL threading-info;
    * src/filter-run-dialog.c (available_list_selection_changed),
      (selected_list_selection_changed):
      no need to disable the "Apply" buttons when the mailbox is not being viewed.

 ChangeLog                | 14 ++++++++++++++
 libbalsa/mailbox.c       | 16 ++++++++++++----
 libbalsa/mailbox_local.c |  8 ++++++--
 src/filter-run-dialog.c  | 10 ++--------
 4 files changed, 34 insertions(+), 14 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index fdfb7c351..56d839307 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2020-06-09  Peter Bloomfield  <pbloomfield bellsouth net>
+
+       Various: restore filtering in a mailbox that is not currently
+       being viewed.
+
+       * libbalsa/mailbox.c (libbalsa_mailbox_message_match),
+       (lbm_cache_message): make sure we cache message info when we need it
+       for matching;
+       * libbalsa/mailbox_local.c (message_match_real): guard against
+       NULL threading-info;
+       * src/filter-run-dialog.c (available_list_selection_changed),
+       (selected_list_selection_changed): no need to disable the
+       "Apply" buttons when the mailbox is not being viewed.
+
 2020-06-08  Peter Bloomfield  <pbloomfield bellsouth net>
 
        filter-run-dialog: Disable "Apply selected" and "Apply now" when
diff --git a/libbalsa/mailbox.c b/libbalsa/mailbox.c
index 603123184..e9c924bd7 100644
--- a/libbalsa/mailbox.c
+++ b/libbalsa/mailbox.c
@@ -168,6 +168,8 @@ struct _LibBalsaMailboxPrivate {
     gboolean msg_tree_changed : 1;
     /* Whether messages have been threaded. */
     gboolean messages_threaded : 1;
+    /* Whether a message should be cached. */
+    gboolean must_cache_message : 1;
 };
 
 #define LBM_GET_INDEX_ENTRY(priv, msgno) \
@@ -811,6 +813,7 @@ libbalsa_mailbox_message_match(LibBalsaMailbox * mailbox,
                                guint msgno,
                                LibBalsaMailboxSearchIter * search_iter)
 {
+    LibBalsaMailboxPrivate *priv = libbalsa_mailbox_get_instance_private(mailbox);
     gboolean match;
 
     g_return_val_if_fail(mailbox != NULL, FALSE);
@@ -822,9 +825,11 @@ libbalsa_mailbox_message_match(LibBalsaMailbox * mailbox,
                                         mailbox, msgno, &match))
         return match;
 
-    return LIBBALSA_MAILBOX_GET_CLASS(mailbox)->message_match(mailbox,
-                                                              msgno,
-                                                              search_iter);
+    priv->must_cache_message = TRUE;
+    match = LIBBALSA_MAILBOX_GET_CLASS(mailbox)->message_match(mailbox, msgno, search_iter);
+    priv->must_cache_message = FALSE;
+
+    return match;
 }
 
 gboolean libbalsa_mailbox_real_can_match(LibBalsaMailbox  *mailbox,
@@ -2008,7 +2013,10 @@ lbm_cache_message(LibBalsaMailbox * mailbox, guint msgno,
     gboolean need_sort;
 
     /* Do we need to cache the message info? */
-    if (priv->mindex == NULL || priv->view == NULL || priv->view->position < 0)
+    if (priv->mindex == NULL)
+        return;
+
+    if ((priv->view == NULL || priv->view->position < 0) && !priv->must_cache_message)
         return;
 
     if (priv->mindex->len < msgno)
diff --git a/libbalsa/mailbox_local.c b/libbalsa/mailbox_local.c
index 22b0f41bc..dd8a27b71 100644
--- a/libbalsa/mailbox_local.c
+++ b/libbalsa/mailbox_local.c
@@ -832,8 +832,12 @@ message_match_real(LibBalsaMailbox *mailbox, guint msgno,
     gboolean is_refed = FALSE;
     LibBalsaMailboxIndexEntry *entry =
         libbalsa_mailbox_get_index_entry(mailbox, msgno);
-    LibBalsaMailboxLocalInfo *info =
-        msgno > 0 && msgno <= priv->threading_info->len ?
+    LibBalsaMailboxLocalInfo *info;
+
+    if (priv->threading_info == NULL)
+        return FALSE;
+
+    info = (msgno > 0 && msgno <= priv->threading_info->len) ?
         g_ptr_array_index(priv->threading_info, msgno - 1) : NULL;
 
     /* We may be able to match the msgno from info cached in entry or
diff --git a/src/filter-run-dialog.c b/src/filter-run-dialog.c
index 5fbe1fe3a..337f47d7a 100644
--- a/src/filter-run-dialog.c
+++ b/src/filter-run-dialog.c
@@ -248,12 +248,9 @@ available_list_selection_changed(GtkTreeSelection *selection,
 {
     BalsaFilterRunDialog *p = user_data;
     gboolean selected;
-    gboolean viewing;
 
     selected = gtk_tree_selection_count_selected_rows(selection) > 0;
-    viewing = balsa_find_notebook_page_num(p->mbox) >= 0;
-
-    gtk_widget_set_sensitive(p->apply_selected_button, selected && viewing);
+    gtk_widget_set_sensitive(p->apply_selected_button, selected);
     gtk_widget_set_sensitive(p->add_button, selected);
 }
 
@@ -264,12 +261,9 @@ selected_list_selection_changed(GtkTreeSelection *selection,
 {
     BalsaFilterRunDialog *p = user_data;
     gboolean selected;
-    gboolean viewing;
 
     selected = gtk_tree_selection_count_selected_rows(selection) > 0;
-    viewing = balsa_find_notebook_page_num(p->mbox) >= 0;
-
-    gtk_widget_set_sensitive(p->apply_now_button, selected && viewing);
+    gtk_widget_set_sensitive(p->apply_now_button, selected);
     gtk_widget_set_sensitive(p->remove_button, selected);
     gtk_widget_set_sensitive(p->move_up_button, selected);
     gtk_widget_set_sensitive(p->move_down_button, selected);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]