Index: ChangeLog
===================================================================
--- ChangeLog	(revision 1340)
+++ ChangeLog	(working copy)
@@ -1,3 +1,13 @@
+2008-04-03  Li Yuan  <li.yuan@sun.com>
+
+	* gail/gailtextview.c: (_gail_text_view_insert_text_cb),
+	(_gail_text_view_delete_range_cb), (emit_text_caret_moved),
+	(insert_handler), (insert_idle_handler):
+	Patch from  Alejandro Piņeiro Iglesias <apinheiro@igalia.com>.
+	Add a function insert_handler which does the work insert_idle_handler
+	used to do. Now insert_idle_handler is a wrapper, only used as idle
+	function. Only call GDK_THREADS_ENTER/LEAVE in insert_idle_handler.
+
 2008-03-10  Li Yuan  <li.yuan@sun.com>
 
 	* NEWS:
Index: gail/gailtextview.c
===================================================================
--- gail/gailtextview.c	(revision 1340)
+++ gail/gailtextview.c	(working copy)
@@ -166,6 +166,7 @@
 static gint             get_selection_bound            (GtkTextBuffer    *buffer);
 static void             emit_text_caret_moved          (GailTextView     *gail_text_view,
                                                         gint             insert_offset);
+static gint             insert_handler                 (gpointer         data);
 static gint             insert_idle_handler            (gpointer         data);
 
 static GailWidgetClass *parent_class = NULL;
@@ -1465,7 +1466,7 @@
           g_source_remove (gail_text_view->insert_notify_handler);
         }
       gail_text_view->insert_notify_handler = 0;
-      insert_idle_handler (gail_text_view);
+      insert_handler (gail_text_view);
       gail_text_view->position = position;
       gail_text_view->length = length;
     }
@@ -1510,7 +1511,7 @@
           return;
         }
 
-      insert_idle_handler (gail_text_view);
+      insert_handler (gail_text_view);
     }
   g_signal_emit_by_name (accessible, "text_changed::delete",
                          offset, length);
@@ -1658,7 +1659,7 @@
     {
       g_source_remove (gail_text_view->insert_notify_handler);
       gail_text_view->insert_notify_handler = 0;
-      insert_idle_handler (gail_text_view);
+      insert_handler (gail_text_view);
     }
 
   if (insert_offset != gail_text_view->previous_insert_offset)
@@ -1675,13 +1676,11 @@
 }
 
 static gint
-insert_idle_handler (gpointer data)
+insert_handler (gpointer data)
 {
   GailTextView *gail_text_view;
   GtkTextBuffer *buffer;
 
-  GDK_THREADS_ENTER ();
-
   gail_text_view = GAIL_TEXT_VIEW (data);
 
   g_signal_emit_by_name (data,
@@ -1703,6 +1702,14 @@
       gail_text_view->previous_selection_bound = get_selection_bound (buffer);
     }
 
+  return FALSE;
+}
+
+static gint
+insert_idle_handler (gpointer data)
+{
+  GDK_THREADS_ENTER ();
+  insert_handler (data);
   GDK_THREADS_LEAVE ();
 
   return FALSE;
