Index: ./widgets/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/widgets/ChangeLog,v
retrieving revision 1.175
diff -u -8 -p -r1.175 ChangeLog
--- ./widgets/ChangeLog	21 Jul 2006 05:47:36 -0000	1.175
+++ ./widgets/ChangeLog	10 Aug 2006 08:53:59 -0000
@@ -1,8 +1,28 @@
+2006-08-10  Mayank Jain  <majain@redhat.com>
+	* text/e-text.c: Applied patches in bug 264485, #61 and bug 348638 #23
+	together to solve bug 264485
+	* bug 264485, #70
+
+2006-07-30  Hiroyuki Ikezoe  <poincare@ikezoe.net>
+
+	** Fixes bug 348638
+	** bug 348638 #23
+	* 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.
+	** bug 264485, #61
+	(e_text_event): call made to reset_layout for old text widgets
+	(e_text_draw): call to update_preedit_string made only when IM context
+	signals are registered
+
+
 2006-07-21  Hiroyuki Ikezoe  <poincare@ikezoe.net>
 
 	** Fixes 342313.
 	* text/e-text.c: Use GTK_CHECK_VERSION instead of GTK_2_2.
 
 2006-07-05  Rajeev ramanathan <rajeevramanathan_2004@yaoo.co.in>
 
 	* text/e-text.[ch]: Added code to render EText text 
Index: ./widgets/text/e-text.c
===================================================================
RCS file: /cvs/gnome/evolution/widgets/text/e-text.c,v
retrieving revision 1.173
diff -u -8 -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	10 Aug 2006 08:54:04 -0000
@@ -272,74 +272,73 @@ e_text_dispose (GObject *object)
 		text->im_context = NULL;
 	}
 
 	if (G_OBJECT_CLASS (parent_class)->dispose)
 		(* G_OBJECT_CLASS (parent_class)->dispose) (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);
 		if (!attrs) {
 			attrs = pango_attr_list_new ();
 			new_attrs = TRUE;
 		}
 
 		pango_layout_set_text (text->layout, tmp_string->str, tmp_string->len);
 
 		pango_attr_list_splice (attrs, preedit_attrs, cpos, preedit_length);
 
 		if (new_attrs) {
 			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)
 {
 	PangoAttrList *attrs = NULL;
 	int object_count;
 
 	if (text->layout == NULL)
 		return;
@@ -1501,19 +1500,19 @@ e_text_draw (GnomeCanvasItem *item, GdkD
 				thisheight += 2;
 
 				gtk_paint_focus (widget->style, widget->window, GTK_WIDGET_STATE (widget),
 						 &area, widget, "button",
 						 thisx + xoff, thisy + yoff, thiswidth - 1, thisheight - 1);
 			}
 		}
 	}
-
-
-	insert_preedit_text (text);	
+	
+	if (text->im_context_signals_registered)
+		update_preedit_text (text);	
 
 	if (!pango_layout_get_text (text->layout))
 		return;
 
 	if (text->stipple)
 		gnome_canvas_set_stipple_origin (item->canvas, main_gc);
 
 	xpos = text->text_cx;
@@ -2216,16 +2215,17 @@ e_text_event (GnomeCanvasItem *item, Gdk
 				 */
 
 				if (save_text && save_text->im_context) {
 					g_signal_handlers_disconnect_matched (save_text->im_context,
 									      G_SIGNAL_MATCH_DATA,
                                                                              0, 0, NULL,
                                                                              NULL, save_text);
                                        save_text->im_context_signals_registered = FALSE;
+                                       reset_layout (save_text);
                                 }
 
 				if (text->im_context) {
 					if (!text->im_context_signals_registered) {
 						g_signal_connect (text->im_context, "commit",
 								  G_CALLBACK (e_text_commit_cb), text);
 						g_signal_connect (text->im_context, "preedit_changed",
 								  G_CALLBACK (e_text_preedit_changed_cb), text);
@@ -2244,16 +2244,17 @@ e_text_event (GnomeCanvasItem *item, Gdk
 				 * disconnecting in the next focus_in.
 				 */
 				if (!text->preedit_len && text->im_context) {
 					g_signal_handlers_disconnect_matched (text->im_context,
 									      G_SIGNAL_MATCH_DATA,
 									      0, 0, NULL,
 									      NULL, text);
 					text->im_context_signals_registered = FALSE;
+					reset_layout (text);
 				} else {
 					save_text = text;
 				}
 
 				e_text_stop_editing (text);
 				if (text->timeout_id) {
 					g_source_remove(text->timeout_id);
 					text->timeout_id = 0;
