[Xfce4-commits] [xfce/thunar] 03/06: Keep the scroll position when restoring the file selection

noreply at xfce.org noreply at xfce.org
Sun May 3 15:00:15 CEST 2015


This is an automated email from the git hooks/post-receive script.

hjudt pushed a commit to branch master
in repository xfce/thunar.

commit bc1351183e50262588d0226d13cc1ace613b524c
Author: Harald Judt <h.judt at gmx.at>
Date:   Fri May 1 14:10:00 2015 +0200

    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;
 }
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list