[patch] scrolling fix for GtkTreeView



This fixes two bugs with explicit scrolling in GtkTreeView.

    1) scrolling to wrong position
    2) not doing queue_redraw, so update happens only when you do something
else to trigger a redraw

There are other oversights in the code, for example scrolling all the way to
the top probably doesn't work perfectly given the code I read, but this does
make things noticeably better. I used the Nautilus theme selector as my test
case.

OK to commit?

Index: gtk/gtktreeview.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtktreeview.c,v
retrieving revision 1.241
diff -p -u -r1.241 gtktreeview.c
--- gtk/gtktreeview.c    2002/02/26 18:56:52    1.241
+++ gtk/gtktreeview.c    2002/02/27 07:28:17
@@ -3661,7 +3661,7 @@ validate_visible_area (GtkTreeView *tree
   GtkTreeIter iter;
   GtkRBTree *tree = NULL;
   GtkRBNode *node = NULL;
-  gboolean validated_area = FALSE;
+  gboolean need_redraw = FALSE;
   gboolean size_changed = FALSE;
   gboolean modify_dy = FALSE;
   gint total_height;
@@ -3684,7 +3684,7 @@ validate_visible_area (GtkTreeView *tree
       if (GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_INVALID) ||
           GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_COLUMN_INVALID))
         {
-          validated_area = TRUE;
+          need_redraw = TRUE;
           if (validate_row (tree_view, tree, node, &iter, path))
         size_changed = TRUE;
         }
@@ -3744,7 +3744,7 @@ validate_visible_area (GtkTreeView *tree
       if (GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_INVALID) ||
       GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_COLUMN_INVALID))
     {
-      validated_area = TRUE;
+      need_redraw = TRUE;
       if (validate_row (tree_view, tree, node, &iter, path))
         size_changed = TRUE;
     }
@@ -3815,7 +3815,7 @@ validate_visible_area (GtkTreeView *tree
       if (GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_INVALID) ||
       GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_COLUMN_INVALID))
     {
-      validated_area = TRUE;
+      need_redraw = TRUE;
       if (validate_row (tree_view, tree, node, &iter, path))
         size_changed = TRUE;
     }
@@ -3844,7 +3844,7 @@ validate_visible_area (GtkTreeView *tree
       if (GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_INVALID) ||
       GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_COLUMN_INVALID))
     {
-      validated_area = TRUE;
+      need_redraw = TRUE;
       if (validate_row (tree_view, tree, node, &iter, above_path))
         size_changed = TRUE;
     }
@@ -3865,7 +3865,8 @@ validate_visible_area (GtkTreeView *tree
       gtk_tree_row_reference_free (tree_view->priv->top_row);
       tree_view->priv->top_row =
     gtk_tree_row_reference_new_proxy (G_OBJECT (tree_view),
tree_view->priv->model, above_path);
-      tree_view->priv->top_row_dy = - area_above;
+      tree_view->priv->top_row_dy = MAX (GTK_RBNODE_GET_HEIGHT (node),
tree_view->priv->expander_size) + area_above;
+      need_redraw = TRUE;
     }
   else
     {
@@ -3887,7 +3888,7 @@ validate_visible_area (GtkTreeView *tree
     }
   if (size_changed)
     gtk_widget_queue_resize (GTK_WIDGET (tree_view));
-  if (validated_area)
+  if (need_redraw)
     gtk_widget_queue_draw (GTK_WIDGET (tree_view));
 }
 
===================================================================

    -- Darin




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]