[balsa] balsa-index: Fix the previous commit



commit e466beb73dcbaee8e0933bd268685a88cd2f7e76
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Sat Jan 18 17:01:00 2020 -0500

    balsa-index: Fix the previous commit
    
    Fix the "mostly" part of the previous commit, by
    using yet another idle handler to allow the tree-view's layout
    settle down.
    
    * src/balsa-index.c (bndx_expand_to_row_and_select_idle): new
      idle handler that scrolls to the desired row;
      (bndx_expand_to_row_and_select): use it, instead of scrolling
      immediately after expanding to the row.

 ChangeLog         | 11 +++++++++++
 src/balsa-index.c | 25 ++++++++++++++++++++++++-
 2 files changed, 35 insertions(+), 1 deletion(-)
---
diff --git a/ChangeLog b/ChangeLog
index a5b00de8c..09e54853e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2020-01-18  Peter Bloomfield  <pbloomfield bellsouth net>
+
+       balsa-index: Fix the "mostly" part of the previous commit, by
+       using yet another idle handler to allow the tree-view's layout
+       settle down.
+
+       * src/balsa-index.c (bndx_expand_to_row_and_select_idle): new
+       idle handler that scrolls to the desired row;
+       (bndx_expand_to_row_and_select): use it, instead of scrolling
+       immediately after expanding to the row.
+
 2020-01-17  Peter Bloomfield  <pbloomfield bellsouth net>
 
        balsa-index: improve expand and collapse
diff --git a/src/balsa-index.c b/src/balsa-index.c
index f82a0d374..d4b6142ec 100644
--- a/src/balsa-index.c
+++ b/src/balsa-index.c
@@ -177,6 +177,9 @@ struct _BalsaIndex {
 
     LibBalsaMailboxSearchIter *search_iter;
     BalsaIndexWidthPreference width_preference;
+
+    /* Ephemeral: used by bndx-expand-to-row-and-select */
+    GtkTreeRowReference *reference;
 };
 
 /* Class type. */
@@ -1318,6 +1321,23 @@ balsa_index_get_next_msgno(BalsaIndex * bindex)
  *
  * Note: iter must be valid; it isn't checked here.
  */
+
+static gboolean
+bndx_expand_to_row_and_select_idle(BalsaIndex *bindex)
+{
+    GtkTreePath *path;
+
+    path = gtk_tree_row_reference_get_path(bindex->reference);
+    gtk_tree_row_reference_free(bindex->reference);
+
+    bndx_select_row(bindex, path);
+    gtk_tree_path_free(path);
+
+    g_object_unref(bindex);
+
+    return G_SOURCE_REMOVE;
+}
+
 static void
 bndx_expand_to_row_and_select(BalsaIndex * index, GtkTreeIter * iter)
 {
@@ -1326,8 +1346,11 @@ bndx_expand_to_row_and_select(BalsaIndex * index, GtkTreeIter * iter)
 
     path = gtk_tree_model_get_path(model, iter);
     bndx_expand_to_row(index, path);
-    bndx_select_row(index, path);
+
+    index->reference = gtk_tree_row_reference_new(model, path);
     gtk_tree_path_free(path);
+
+    g_idle_add((GSourceFunc) bndx_expand_to_row_and_select_idle, g_object_ref(index));
 }
 
 /* End of select message interfaces. */


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