[balsa] Various: Fix some more mailbox-opening issues



commit 191c544c8d530c85e76e86dcee875d9f79f9e63c
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Thu Aug 20 16:48:39 2020 -0400

    Various: Fix some more mailbox-opening issues
    
    * libbalsa/mailbox.c (libbalsa_mailbox_get_has_sort_pending): new function;
    * libbalsa/mailbox.h: declare it;
    * src/balsa-index.c (bndx_scroll_on_open_idle): use it;
    * src/main-window.c
      (bw_real_open_mbnode_idle_cb): show the BalsaIndex widget here,
        instead of in the scroll-on-open idle handler;
      (balsa_window_next_unread): balsa_index_select_next_unread()
        finds the next unread message even if it is hidden.

 ChangeLog          | 14 ++++++++++++++
 libbalsa/mailbox.c | 10 ++++++++++
 libbalsa/mailbox.h |  1 +
 src/balsa-index.c  | 16 +++++++++-------
 src/main-window.c  |  9 +++------
 5 files changed, 37 insertions(+), 13 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 9c4afdc46..cbfbc74d3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2020-08-20  Peter Bloomfield  <pbloomfield bellsouth net>
+
+       Fix some more mailbox-opening issues
+
+       * libbalsa/mailbox.c (libbalsa_mailbox_get_has_sort_pending):
+         new function;
+       * libbalsa/mailbox.h: declare it;
+       * src/balsa-index.c (bndx_scroll_on_open_idle): use it;
+       * src/main-window.c (bw_real_open_mbnode_idle_cb): show the
+         BalsaIndex widget here, instead of in the scroll-on-open idle
+         handler
+       (balsa_window_next_unread): balsa_index_select_next_unread()
+         finds the next unread message even if it is hidden.
+
 2020-08-17  Peter Bloomfield  <pbloomfield bellsouth net>
 
        balsa-message: Restore text copy
diff --git a/libbalsa/mailbox.c b/libbalsa/mailbox.c
index 5c002a580..27b0d278d 100644
--- a/libbalsa/mailbox.c
+++ b/libbalsa/mailbox.c
@@ -4929,6 +4929,16 @@ libbalsa_mailbox_get_messages_threaded(LibBalsaMailbox * mailbox)
     return priv->messages_threaded != 0;
 }
 
+gboolean
+libbalsa_mailbox_get_has_sort_pending(LibBalsaMailbox * mailbox)
+{
+    LibBalsaMailboxPrivate *priv = libbalsa_mailbox_get_instance_private(mailbox);
+
+    g_return_val_if_fail(LIBBALSA_IS_MAILBOX(mailbox), FALSE);
+
+    return priv->sort_idle_id != 0;
+}
+
 /*
  * Setters
  */
diff --git a/libbalsa/mailbox.h b/libbalsa/mailbox.h
index 1ba5b164a..bc3c5eb6b 100644
--- a/libbalsa/mailbox.h
+++ b/libbalsa/mailbox.h
@@ -623,6 +623,7 @@ gboolean libbalsa_mailbox_get_readonly(LibBalsaMailbox * mailbox);
 const gchar * libbalsa_mailbox_get_config_prefix(LibBalsaMailbox * mailbox);
 gboolean libbalsa_mailbox_get_has_unread_messages(LibBalsaMailbox * mailbox);
 gboolean libbalsa_mailbox_get_messages_threaded(LibBalsaMailbox * mailbox);
+gboolean libbalsa_mailbox_get_has_sort_pending(LibBalsaMailbox * mailbox);
 
 /*
  * Setters
diff --git a/src/balsa-index.c b/src/balsa-index.c
index b0921ad62..ee64d9ec9 100644
--- a/src/balsa-index.c
+++ b/src/balsa-index.c
@@ -862,21 +862,24 @@ bndx_scroll_on_open_idle(BalsaIndex *bindex)
     if (!libbalsa_mailbox_get_messages_threaded(mailbox))
         return TRUE; /* G_SOURCE_CONTINUE */
 
+    if (libbalsa_mailbox_get_has_sort_pending(mailbox))
+        return TRUE; /* G_SOURCE_CONTINUE */
+
     if (balsa_app.expand_tree &&
         libbalsa_mailbox_get_threading_type(mailbox) != LB_MAILBOX_THREADING_FLAT &&
         !bindex->expanded) {
         gtk_tree_view_expand_all(tree_view);
         bindex->expanded = TRUE;
+
         return TRUE; /* G_SOURCE_CONTINUE */
     }
 
     first_unread = libbalsa_mailbox_get_first_unread(mailbox);
     if (first_unread > 0) {
         libbalsa_mailbox_set_first_unread(mailbox, 0);
-        if (!libbalsa_mailbox_msgno_find(mailbox, first_unread, &path, NULL)) {
-            gtk_widget_show(GTK_WIDGET(bindex));
+
+        if (!libbalsa_mailbox_msgno_find(mailbox, first_unread, &path, NULL))
             return FALSE; /* Oops! */
-        }
     } else {
         /* we want to scroll to the last one in current order. The
            alternative which is to scroll to the most recently
@@ -884,10 +887,10 @@ bndx_scroll_on_open_idle(BalsaIndex *bindex)
            used */
         gint n_children =
             gtk_tree_model_iter_n_children(GTK_TREE_MODEL(mailbox), NULL);
-        if (n_children == 0) {
-            gtk_widget_show(GTK_WIDGET(bindex));
+
+        if (n_children == 0)
             return FALSE;
-        }
+
         path = gtk_tree_path_new_from_indices(n_children - 1, -1);
     }
 
@@ -913,7 +916,6 @@ bndx_scroll_on_open_idle(BalsaIndex *bindex)
     }
 
     gtk_tree_path_free(path);
-    gtk_widget_show(GTK_WIDGET(bindex));
 
     return FALSE;
 }
diff --git a/src/main-window.c b/src/main-window.c
index c35ec4b82..cb501c3b1 100644
--- a/src/main-window.c
+++ b/src/main-window.c
@@ -2895,6 +2895,7 @@ bw_real_open_mbnode_idle_cb(BalsaWindowRealOpenMbnodeInfo * info)
 
     /* scroll may select the message and GtkTreeView does not like selecting
      * without being shown first. */
+    gtk_widget_show(GTK_WIDGET(index));
     balsa_index_scroll_on_open(index);
 
     g_ptr_array_remove_fast(priv->open_mbnode_info_array, info);
@@ -4819,12 +4820,8 @@ balsa_window_next_unread(BalsaWindow * window)
     LibBalsaMailbox *mailbox = index ? balsa_index_get_mailbox(index): NULL;
 
     if (libbalsa_mailbox_get_unread(mailbox) > 0) {
-        if (!balsa_index_select_next_unread(index)) {
-            /* All unread messages must be hidden; we assume that the
-             * user wants to see them, and try again. */
-            bw_reset_filter(window);
-            balsa_index_select_next_unread(index);
-        }
+        balsa_index_select_next_unread(index);
+
         return FALSE;
     }
 


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