Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gal/ChangeLog,v
retrieving revision 1.924
diff -u -p -r1.924 ChangeLog
--- ChangeLog	21 Apr 2005 08:57:17 -0000	1.924
+++ ChangeLog	21 Apr 2005 09:47:56 -0000
@@ -1,5 +1,16 @@
 2005-04-21  Mengjie Yu  <meng-jie.yu@sun.com>
 
+
+	* gal/widgets/e-reflow.c: (do_adjustment), (cursor_changed),
+	(e_reflow_dispose), (e_reflow_init):
+	use idle callback to adjust scrollbar when focus has been changed.
+	* gal/widgets/e-reflow.h:
+	add source ID field for idle callback
+
+	Fixes #300954
+
+2005-04-21  Mengjie Yu  <meng-jie.yu@sun.com>
+
 	* gal/widgets/e-selection-model.c: (e_selection_model_key_press):
 	break while row equals -1.
 
Index: gal/widgets/e-reflow.c
===================================================================
RCS file: /cvs/gnome/gal/gal/widgets/e-reflow.c,v
retrieving revision 1.56
diff -u -p -r1.56 e-reflow.c
--- gal/widgets/e-reflow.c	4 Mar 2005 09:16:36 -0000	1.56
+++ gal/widgets/e-reflow.c	21 Apr 2005 09:48:09 -0000
@@ -160,6 +160,37 @@ selection_row_changed (ESelectionModel *
 	e_reflow_update_selection_row (reflow, row);
 }
 
+static gboolean
+do_adjustment (gpointer user_data)
+{
+	int row;
+	GtkAdjustment *adj ;
+	gfloat value, min_value, max_value;
+	EReflow *reflow = user_data;
+
+	adj = gtk_layout_get_hadjustment (GTK_LAYOUT (GNOME_CANVAS_ITEM (reflow)->canvas));
+	row = reflow->cursor_row;
+	value = adj->value;
+
+	min_value = reflow->items[row]->x2 - adj->page_size;
+	max_value = reflow->items[row]->x1;
+
+	if (value < min_value)
+		value = min_value;
+
+	if (value > max_value)
+		value = max_value;
+
+	if (value != adj->value) {
+		adj->value = value;
+		gtk_adjustment_value_changed (adj);
+	}
+
+	reflow->do_adjustment_idle_id = 0;
+	
+	return FALSE;
+}
+
 static void
 cursor_changed (ESelectionModel *selection, int row, int col, EReflow *reflow)
 {
@@ -189,8 +220,13 @@ cursor_changed (ESelectionModel *selecti
 				      NULL);
 		}
 	}
+	
+	if (reflow->do_adjustment_idle_id == 0)
+		reflow->do_adjustment_idle_id = g_idle_add (do_adjustment, reflow);
+	
 }
 
+
 static void
 incarnate (EReflow *reflow)
 {
@@ -767,6 +803,10 @@ e_reflow_dispose (GObject *object)
 		g_source_remove (reflow->incarnate_idle_id);
 	reflow->incarnate_idle_id = 0;
 
+	if (reflow->do_adjustment_idle_id)
+		g_source_remove (reflow->do_adjustment_idle_id);
+	reflow->do_adjustment_idle_id = 0;	
+
 	disconnect_model (reflow);
 	disconnect_selection (reflow);
 	
@@ -1479,6 +1519,7 @@ e_reflow_init (EReflow *reflow)
 	reflow->cursor_row                = -1;
 
 	reflow->incarnate_idle_id         = 0;
+	reflow->do_adjustment_idle_id     = 0;
 	reflow->set_scroll_adjustments_id = 0;
 
 	reflow->selection                 = E_SELECTION_MODEL (e_selection_model_simple_new());
Index: gal/widgets/e-reflow.h
===================================================================
RCS file: /cvs/gnome/gal/gal/widgets/e-reflow.h,v
retrieving revision 1.18
diff -u -p -r1.18 e-reflow.h
--- gal/widgets/e-reflow.h	17 Feb 2003 02:38:15 -0000	1.18
+++ gal/widgets/e-reflow.h	21 Apr 2005 09:48:10 -0000
@@ -98,6 +98,7 @@ struct _EReflow
 	double column_width;
 
 	int incarnate_idle_id;
+	int do_adjustment_idle_id;
 
 	/* These are all for when the column is being dragged. */
 	gdouble start_x;
