[evolution-patches] 42126: etree scroll adjustment - 2nd try



This moves the same code from the reflow handler to the size_alloc
handler so that it's done less frequently.  This solves the bug with
less (I hesitate to say no) side effects.

Mike

On Thu, 2003-05-08 at 15:57, Mike Kestner wrote:

> ETree only ever really adjusted it's scroll position on user input,
> which would lead to trees being shown with the cursor out of view
> occasionally.  This patch causes the cursor to be centered in the canvas
> view whenever the canvas is reflown, ie whenever it changes size and on
> initial display.
> 
> Mike
Index: gal/e-table/ChangeLog
===================================================================
RCS file: /cvs/gnome/gal/gal/e-table/ChangeLog,v
retrieving revision 1.893
diff -u -p -r1.893 ChangeLog
--- gal/e-table/ChangeLog	6 May 2003 18:19:15 -0000	1.893
+++ gal/e-table/ChangeLog	9 May 2003 16:22:14 -0000
@@ -1,3 +1,10 @@
+2003-05-08  Mike Kestner  <mkestner ximian com>
+
+	* e-table-item.c (eti_cursor_change): don't return on col == -1. 
+	* e-tree.c (tree_canvas_size_allocate): update the adjustment 
+	to center the cursor.
+	(hover_timeout): remove unused variable to fix warning
+
 2003-05-06  Mike Kestner  <mkestner ximian com>
 
 	* e-tree-table-adapter.c (insert_node): add missing model_changed
Index: gal/e-table/e-table-item.c
===================================================================
RCS file: /cvs/gnome/gal/gal/e-table/e-table-item.c,v
retrieving revision 1.220
diff -u -p -r1.220 e-table-item.c
--- gal/e-table/e-table-item.c	8 Apr 2003 14:36:55 -0000	1.220
+++ gal/e-table/e-table-item.c	9 May 2003 16:22:16 -0000
@@ -3121,7 +3121,7 @@ eti_cursor_change (ESelectionModel *sele
 	if (eti->old_cursor_row != -1 && view_row != eti->old_cursor_row)
 		e_table_item_redraw_row (eti, eti->old_cursor_row);
 
-	if (view_row == -1 || view_col == -1) {
+	if (view_row == -1) {
 		e_table_item_leave_edit_(eti);
 		eti->old_cursor_row = -1;
 		return;
Index: gal/e-table/e-tree.c
===================================================================
RCS file: /cvs/gnome/gal/gal/e-table/e-tree.c,v
retrieving revision 1.97
diff -u -p -r1.97 e-tree.c
--- gal/e-table/e-tree.c	2 Apr 2003 23:34:36 -0000	1.97
+++ gal/e-table/e-tree.c	9 May 2003 16:22:17 -0000
@@ -747,6 +747,9 @@ tree_canvas_size_allocate (GtkWidget *wi
 	gdouble width;
 	gdouble height;
 	gdouble item_height;
+	GtkAdjustment *adj = GTK_LAYOUT(e_tree->priv->table_canvas)->vadjustment;
+	ETreePath path = e_tree_get_cursor (e_tree);
+	gint x, y, w, h;
 	GValue *val = g_new0 (GValue, 1);
 	g_value_init (val, G_TYPE_DOUBLE);
 
@@ -763,6 +766,16 @@ tree_canvas_size_allocate (GtkWidget *wi
 		      NULL);
 	g_object_set_property (G_OBJECT (e_tree->priv->header), "width", val);
 	g_free (val);
+
+	if (path)
+		e_tree_get_cell_geometry (e_tree, e_tree_row_of_node(e_tree, path), 0, &x, &y, &w, &h);
+	else
+		y = h = 0;
+
+	printf("y=%d h=%d in table_canvas_size_allocated\n", y, h);
+	if (y < adj->value || y + h > adj->value + adj->page_size)
+		gtk_adjustment_set_value(adj, CLAMP(y - adj->page_size / 2, adj->lower, adj->upper - adj->page_size));
+
 	if (e_tree->priv->reflow_idle_id)
 		g_source_remove(e_tree->priv->reflow_idle_id);
 	tree_canvas_reflow_idle(e_tree);
@@ -2716,7 +2729,6 @@ static gboolean
 hover_timeout (gpointer data)
 {
 	ETree *et = data;
-	GtkWidget *widget = data;
 	int x = et->priv->hover_x;
 	int y = et->priv->hover_y;
 	int row, col;


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