Commit bc135118 authored by Harald Judt's avatar Harald Judt

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.
parent 8ed38783
......@@ -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;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment