From bcfb57f4c1088fcf68a16addc56b8846cb265cdd Mon Sep 17 00:00:00 2001
From: Raymond Liu <raymond.liu@intel.com>
Date: Mon, 9 Mar 2009 14:10:45 +0800
Subject: [PATCH] clutter-text.c: in clutter_text_insert_text, insert text into the right position, and
 set new cursor position accordingly.

---
 clutter/clutter-text.c |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/clutter/clutter-text.c b/clutter/clutter-text.c
index 0f5c66c..6e74e09 100644
--- a/clutter/clutter-text.c
+++ b/clutter/clutter-text.c
@@ -3691,17 +3691,26 @@ clutter_text_insert_text (ClutterText *self,
 {
   ClutterTextPrivate *priv;
   GString *new = NULL;
+  gint pos_bytes;
 
   g_return_if_fail (CLUTTER_IS_TEXT (self));
   g_return_if_fail (text != NULL);
 
   priv = self->priv;
 
+  pos_bytes = offset_to_bytes (priv->text, position);
+
   new = g_string_new (priv->text);
-  new = g_string_insert (new, position, text);
+  new = g_string_insert (new, pos_bytes, text);
 
   clutter_text_set_text (self, new->str);
 
+  if (position >= 0 && priv->position >= position)
+    {
+      clutter_text_set_cursor_position (self, priv->position + g_utf8_strlen (text, -1));
+      clutter_text_set_selection_bound (self, priv->position);
+    }
+
   g_string_free (new, TRUE);
 }
 
-- 
1.5.6.3

