[rhythmbox] property-view: only scroll to newly selected property if not visible



commit df838d303651103ff4fc523a28dd3059d6c86f6a
Author: Jonathan Matthew <jonathan d14n org>
Date:   Wed Sep 23 22:54:49 2020 +1000

    property-view: only scroll to newly selected property if not visible
    
    This was particularly annoying when selecting a property to show a
    popup menu for it - the view would scroll so the property was in the
    middle, but the menu would be shown next to the pointer.

 widgets/rb-property-view.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
---
diff --git a/widgets/rb-property-view.c b/widgets/rb-property-view.c
index 2195f1162..577b61eb8 100644
--- a/widgets/rb-property-view.c
+++ b/widgets/rb-property-view.c
@@ -797,12 +797,20 @@ rb_property_view_set_selection (RBPropertyView *view,
                        gtk_tree_selection_select_iter (view->priv->selection, &iter);
                        path = gtk_tree_model_get_path (GTK_TREE_MODEL (view->priv->prop_model), &iter);
                        if (path != NULL) {
-                               gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (view->priv->treeview),
-                                                             path, NULL, TRUE,
-                                                             0.5, 0.0);
+                               GtkTreePath *start_path, *end_path;
+
+                               if (gtk_tree_view_get_visible_range (GTK_TREE_VIEW (view->priv->treeview), 
&start_path, &end_path)) {
+                                       if (gtk_tree_path_compare (path, start_path) < 0 ||
+                                           gtk_tree_path_compare (path, end_path) > 0) {
+                                               gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW 
(view->priv->treeview),
+                                                                             path, NULL, TRUE,
+                                                                             0.5, 0.0);
+                                       }
+                                       gtk_tree_path_free (start_path);
+                                       gtk_tree_path_free (end_path);
+                               }
                                gtk_tree_path_free (path);
                        }
-
                }
        }
 


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