# HG changeset patch # User nadvornik # Date 1244286909 0 # Node ID 0a72cb859b4938e27ee4ec6df4ce9a7545717806 # Parent 66bf394d162a6c028797835e50587c1fbfee972b reduced jumping of directory tree when user clicks on folders diff -r 66bf394d162a -r 0a72cb859b49 src/view_dir_tree.c --- a/src/view_dir_tree.c Fri Jun 05 21:52:37 2009 +0000 +++ b/src/view_dir_tree.c Sat Jun 06 11:15:09 2009 +0000 @@ -694,13 +694,10 @@ if (vd_find_row(vd, fd, &iter)) { GtkTreeModel *store; - GtkTreePath *tpath; + GtkTreePath *tpath, *old_tpath; GtkTreeSelection *selection; store = gtk_tree_view_get_model(GTK_TREE_VIEW(vd->view)); - tpath = gtk_tree_model_get_path(store, &iter); - gtk_tree_view_set_cursor(GTK_TREE_VIEW(vd->view), tpath, NULL, FALSE); - gtk_tree_path_free(tpath); selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vd->view)); @@ -709,7 +706,16 @@ gtk_tree_selection_select_iter(selection, &iter); selection_is_ok = FALSE; - tree_view_row_make_visible(GTK_TREE_VIEW(vd->view), &iter, TRUE); + gtk_tree_view_get_cursor(GTK_TREE_VIEW(vd->view), &old_tpath, NULL); + tpath = gtk_tree_model_get_path(store, &iter); + + if (!old_tpath || gtk_tree_path_compare(tpath, old_tpath) != 0) + { + /* setting the cursor scrolls the view; do not do that unless it is necessary */ + gtk_tree_view_set_cursor(GTK_TREE_VIEW(vd->view), tpath, NULL, FALSE); + } + gtk_tree_path_free(tpath); + gtk_tree_path_free(old_tpath); } return TRUE;