From 091f6cadb3af8349584c63db8eb73c7818405811 Mon Sep 17 00:00:00 2001 From: Harald Judt Date: Fri, 1 May 2015 14:10:00 +0200 Subject: Keep the scroll position when restoring the file selection Instead of trying to keep the selected files in view when rows get reordered, leave the scroll position unchanged. Otherwise, the user might not be able to select files easily. By setting fix lower/upper limits for the scrolled window alignments we make sure that the view does not flicker because the position would change twice. --- thunar/thunar-standard-view.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/thunar/thunar-standard-view.c b/thunar/thunar-standard-view.c index 550545c..d06ed12 100644 --- a/thunar/thunar-standard-view.c +++ b/thunar/thunar-standard-view.c @@ -3674,10 +3674,30 @@ thunar_standard_view_row_deleted (ThunarListModel *model, static gboolean thunar_standard_view_restore_selection_idle (ThunarStandardView *standard_view) { + GtkAdjustment *hadjustment; + GtkAdjustment *vadjustment; + gdouble h, v, hl, hu, vl, vu; + _thunar_return_val_if_fail (THUNAR_IS_STANDARD_VIEW (standard_view), FALSE); + /* save the current scroll position and limits */ + hadjustment = gtk_scrolled_window_get_hadjustment (GTK_SCROLLED_WINDOW (standard_view)); + vadjustment = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (standard_view)); + g_object_get (G_OBJECT (hadjustment), "value", &h, "lower", &hl, "upper", &hu, NULL); + g_object_get (G_OBJECT (vadjustment), "value", &v, "lower", &vl, "upper", &vu, NULL); + + /* keep the current scroll position by setting the limits to the current value */ + g_object_set (G_OBJECT (hadjustment), "lower", h, "upper", h, NULL); + g_object_set (G_OBJECT (vadjustment), "lower", v, "upper", v, NULL); + + /* restore the selection */ thunar_component_restore_selection (THUNAR_COMPONENT (standard_view)); standard_view->priv->restore_selection_idle_id = 0; + + /* unfreeze the scroll position */ + g_object_set (G_OBJECT (hadjustment), "value", h, "lower", hl, "upper", hu, NULL); + g_object_set (G_OBJECT (vadjustment), "value", v, "lower", vl, "upper", vu, NULL); + return FALSE; } -- 2.3.6