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	25 Jul 2006 10:13:15 -0000
@@ -1503,17 +1503,18 @@ e_text_draw (GnomeCanvasItem *item, GdkD
 				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)
+		insert_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;
@@ -2211,35 +2212,38 @@ e_text_event (GnomeCanvasItem *item, Gdk
 				 * Here when a new text widget comes into focus we can disconnect the 
 				 * old one.Shouldn't hurt much, as in worst case, save_text which should
 				 * be disconnected will be overwritten and we will have signal 
 			   	 * handlers connect to  multiple e-texts but with subsequent commit these 
 				 * should go away.
 				 */
 
 				if (save_text && save_text->im_context) {
+					gtk_im_context_focus_out(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;
+                                        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);
 						g_signal_connect (text->im_context, "retrieve_surrounding",
 								  G_CALLBACK (e_text_retrieve_surrounding_cb), text);
 						g_signal_connect (text->im_context, "delete_surrounding",
 								  G_CALLBACK (e_text_delete_surrounding_cb), text);
 						text->im_context_signals_registered = TRUE;
 					}
+					gtk_im_context_focus_in(text->im_context);
 				}
 				start_editing (text);
 				text->show_cursor = FALSE; /* so we'll redraw and the cursor will be shown */
 			} else {
 				/* Incase we are not disconnecting the signals 
 				 * for text, we are saving text for 
 				 * disconnecting in the next focus_in.
 				 */
