[balsa] balsa-index: improve ensure-visible



commit 1bef67413c0ee9875690efd9cb03e0ff29c8c350
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Sun Jan 19 16:08:09 2020 -0500

    balsa-index: improve ensure-visible
    
    * src/balsa-index.c (balsa_index_ensure_visible): if some message either
      is selected or has the focus, scroll to it.

 ChangeLog         |  7 +++++++
 src/balsa-index.c | 45 +++++++++++++++++++++++++--------------------
 2 files changed, 32 insertions(+), 20 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index c3500bf8b..a81dd7f4c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2020-01-19  Peter Bloomfield  <pbloomfield bellsouth net>
+
+       balsa-index: improve ensure-visible
+
+       * src/balsa-index.c (balsa_index_ensure_visible): if either a
+       message is selected or has the focus, scroll to it.
+
 2020-01-19  Albrecht Dreß  <albrecht dress arcor de>
 
        * README: fix package requirements
diff --git a/src/balsa-index.c b/src/balsa-index.c
index a92a268f2..5a2262cf1 100644
--- a/src/balsa-index.c
+++ b/src/balsa-index.c
@@ -2737,26 +2737,31 @@ balsa_index_ensure_visible(BalsaIndex * index)
     if (!bndx_find_current_msgno(index, &path, NULL)) {
         /* Current message not displayed, make sure that something
            else is... */
-        gtk_tree_view_get_visible_rect(tree_view, &rect);
-        gtk_tree_view_convert_tree_to_widget_coords(tree_view,
-                                                    rect.x, rect.y,
-                                                    &rect.x, &rect.y);
-
-        if (gtk_tree_view_get_path_at_pos(tree_view, rect.x, rect.y, &path,
-                                          NULL, NULL, NULL)) {
-            /* We have a message in the view, so we do nothing. */
-            gtk_tree_path_free(path);
-            path = NULL;
-        } else {
-            /* Scroll to the last message. */
-            GtkTreeModel *model;
-            gint n_children;
-
-            model = gtk_tree_view_get_model(tree_view);
-            n_children = gtk_tree_model_iter_n_children(model, NULL);
-
-            if (n_children > 0)
-                path = gtk_tree_path_new_from_indices(n_children - 1, -1);
+        /* Was the cursor set? */
+        gtk_tree_view_get_cursor(tree_view, &path, NULL);
+        if (path == NULL) {
+            /* No */
+            gtk_tree_view_get_visible_rect(tree_view, &rect);
+            gtk_tree_view_convert_tree_to_widget_coords(tree_view,
+                                                        rect.x, rect.y,
+                                                        &rect.x, &rect.y);
+
+            if (gtk_tree_view_get_path_at_pos(tree_view, rect.x, rect.y, &path,
+                                              NULL, NULL, NULL)) {
+                /* We have a message in the view, so we do nothing. */
+                gtk_tree_path_free(path);
+                path = NULL;
+            } else {
+                /* Scroll to the last message. */
+                GtkTreeModel *model;
+                gint n_children;
+
+                model = gtk_tree_view_get_model(tree_view);
+                n_children = gtk_tree_model_iter_n_children(model, NULL);
+
+                if (n_children > 0)
+                    path = gtk_tree_path_new_from_indices(n_children - 1, -1);
+            }
         }
     }
 


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