Index: widgets/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/widgets/ChangeLog,v
retrieving revision 1.175
diff -u -p -r1.175 ChangeLog
--- widgets/ChangeLog	21 Jul 2006 05:47:36 -0000	1.175
+++ widgets/ChangeLog	30 Jul 2006 09:53:56 -0000
@@ -1,3 +1,12 @@
+2006-07-30  Hiroyuki Ikezoe  <poincare@ikezoe.net>
+
+	** Fixes bug 348638
+	* text/e-text.c: (update_preedit_string): New function renamed from
+	insert_preedit_string. Now this function handles not only insertion of
+	preedit string but also deletion.
+	(e_text_draw): Call update_preedit_string instead of
+	insert_preedit_string.
+
 2006-07-21  Hiroyuki Ikezoe  <poincare@ikezoe.net>
 
 	** Fixes 342313.
Index: widgets/text/e-text.c
===================================================================
RCS file: /cvs/gnome/evolution/widgets/text/e-text.c,v
retrieving revision 1.173
diff -u -p -r1.173 e-text.c
--- widgets/text/e-text.c	21 Jul 2006 05:47:37 -0000	1.173
+++ widgets/text/e-text.c	30 Jul 2006 09:53:57 -0000
@@ -277,38 +277,35 @@ e_text_dispose (GObject *object)
 }
 
 static void
-insert_preedit_text (EText *text)
+update_preedit_text (EText *text)
 {
-	PangoAttrList *attrs = NULL;
 	PangoAttrList *preedit_attrs = NULL;
 	gchar *preedit_string = NULL;
-	GString *tmp_string = g_string_new (NULL);
-	gint length = 0, cpos = 0, preedit_length = 0;
-	gboolean new_attrs = FALSE;
+	gint length = 0, preedit_length = 0;
 
 	if (text->layout == NULL || !GTK_IS_IM_CONTEXT (text->im_context))
 		return;
 
-	text->text = e_text_model_get_text(text->model);
-	length = strlen (text->text);
-
-	g_string_prepend_len (tmp_string, text->text,length); 
-
-	if (text->preedit_len)
-		gtk_im_context_get_preedit_string (text->im_context,
+	gtk_im_context_get_preedit_string (text->im_context,
 					   &preedit_string, &preedit_attrs,
 					   NULL);
-
-	if (preedit_string && g_utf8_validate (preedit_string, -1, NULL))
+	if (g_utf8_validate (preedit_string, -1, NULL))
 		text->preedit_len = preedit_length = strlen (preedit_string);
 	else
-		text->preedit_len  = preedit_length = 0;
+		text->preedit_len = preedit_length = 0;
 
-	cpos = g_utf8_offset_to_pointer (text->text, text->selection_start) - text->text;	
+	text->text = e_text_model_get_text(text->model);
+	length = strlen (text->text);
 
 	if (preedit_length) {
-		g_string_insert (tmp_string, cpos, preedit_string);
+		PangoAttrList *attrs = NULL;
+		gboolean new_attrs = FALSE;
+		gint cpos = 0;
+		GString *tmp_string = g_string_new (text->text);
 
+		cpos = g_utf8_offset_to_pointer (text->text, text->selection_start) - text->text;	
+		g_string_insert (tmp_string, cpos, preedit_string);
+		
 		reset_layout_attrs (text);
 
 		attrs = pango_layout_get_attributes (text->layout);
@@ -325,16 +322,18 @@ insert_preedit_text (EText *text)
 			pango_layout_set_attributes (text->layout, attrs);
 			pango_attr_list_unref (attrs);
 		}
+
+		g_string_free (tmp_string, TRUE);
+	} else {
+		pango_layout_set_text (text->layout, text->text, length);
 	}
 
-	if (preedit_string)
-		g_free (preedit_string);
+	g_free (preedit_string);
 	if (preedit_attrs)
 		pango_attr_list_unref (preedit_attrs);
-	if (tmp_string)
-		g_string_free (tmp_string, TRUE);
 }
 
+
 static void
 reset_layout_attrs (EText *text)
 {
@@ -1507,8 +1506,7 @@ e_text_draw (GnomeCanvasItem *item, GdkD
 		}
 	}
 
-
-	insert_preedit_text (text);	
+	update_preedit_text (text);	
 
 	if (!pango_layout_get_text (text->layout))
 		return;
