Skip to content

Commit

Permalink
property-view: only scroll to newly selected property if not visible
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Jonathan Matthew committed Sep 23, 2020
1 parent 9af3692 commit df838d3
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions widgets/rb-property-view.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

}
}

Expand Down

0 comments on commit df838d3

Please sign in to comment.