Index: gtk/gtkentry.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkentry.c,v
retrieving revision 1.308
diff -u -p -r1.308 gtkentry.c
--- gtk/gtkentry.c	22 Mar 2006 14:06:40 -0000	1.308
+++ gtk/gtkentry.c	22 Mar 2006 14:53:37 -0000
@@ -72,6 +72,7 @@
 
 static const GtkBorder default_inner_border = { 2, 2, 2, 2 };
 static GQuark          quark_inner_border   = 0;
+static GQuark          quark_last_char      = 0;
 
 typedef struct _GtkEntryPrivate GtkEntryPrivate;
 
@@ -81,7 +82,12 @@ struct _GtkEntryPrivate 
 {
   gfloat xalign;
   gint insert_pos;
+};
+
+typedef struct _GtkEntryLastChar GtkEntryLastChar;
 
+struct _GtkEntryLastChar
+{
   gchar last_char[LAST_CHAR_MAX];
   guint last_char_timeout_id;
   gint  last_char_length;
@@ -497,6 +503,7 @@ gtk_entry_class_init (GtkEntryClass *cla
   class->activate = gtk_entry_real_activate;
   
   quark_inner_border = g_quark_from_static_string ("gtk-entry-inner-border");
+  quark_last_char = g_quark_from_static_string ("gtk-entry-last-char");
 
   g_object_class_install_property (gobject_class,
                                    PROP_CURSOR_POSITION,
@@ -1111,11 +1118,6 @@ gtk_entry_init (GtkEntry *entry)
   entry->truncate_multiline = FALSE;
   priv->xalign = 0.0;
 
-  memset (&priv->last_char, 0, LAST_CHAR_MAX);
-  priv->last_char_timeout_id = 0;
-  priv->last_char_length = 0;
-  priv->last_char_position = 0;
-
   gtk_drag_dest_set (GTK_WIDGET (entry),
                      GTK_DEST_DEFAULT_HIGHLIGHT,
                      NULL, 0,
@@ -1183,7 +1185,6 @@ static void
 gtk_entry_finalize (GObject *object)
 {
   GtkEntry *entry = GTK_ENTRY (object);
-  GtkEntryPrivate *priv = GTK_ENTRY_GET_PRIVATE (entry);
 
   gtk_entry_set_completion (entry, NULL);
 
@@ -1198,9 +1199,6 @@ gtk_entry_finalize (GObject *object)
   if (entry->recompute_idle)
     g_source_remove (entry->recompute_idle);
 
-  if (priv->last_char_timeout_id)
-    g_source_remove (priv->last_char_timeout_id);
-
   entry->text_size = 0;
 
   if (entry->text)
@@ -2354,6 +2352,15 @@ gtk_entry_start_editing (GtkCellEditable
 		    G_CALLBACK (gtk_cell_editable_key_press_event), NULL);
 }
 
+static void
+gtk_entry_last_char_free (GtkEntryLastChar *last_char)
+{
+  if (last_char->last_char_timeout_id)
+    g_source_remove (last_char->last_char_timeout_id);
+
+  g_free (last_char);
+}
+
 /* Default signal handlers
  */
 static void
@@ -2363,7 +2370,6 @@ gtk_entry_real_insert_text (GtkEditable 
 			    gint        *position)
 {
   GtkEntry *entry = GTK_ENTRY (editable);
-  GtkEntryPrivate *priv  = GTK_ENTRY_GET_PRIVATE (entry);
   gint index;
   gint n_chars;
   guint last_char_timeout;
@@ -2443,10 +2449,25 @@ gtk_entry_real_insert_text (GtkEditable 
   if (last_char_timeout > 0 && n_chars == 1 && !entry->visible &&
       (new_text_length < LAST_CHAR_MAX))
     {
-      memset (&priv->last_char, 0x0, LAST_CHAR_MAX);
-      priv->last_char_length = new_text_length;
-      memcpy (&priv->last_char, new_text, new_text_length);
-      priv->last_char_position = *position + n_chars;
+      GtkEntryLastChar *last_char = g_object_get_qdata (G_OBJECT (entry),
+                                                        quark_last_char);
+
+      if (! last_char)
+        {
+          last_char = g_new0 (GtkEntryLastChar, 1);
+          g_object_set_qdata_full (G_OBJECT (entry), quark_last_char,
+                                   last_char,
+                                   (GDestroyNotify) gtk_entry_last_char_free);
+        }
+
+      memset (&last_char->last_char, 0x0, LAST_CHAR_MAX);
+      last_char->last_char_length = new_text_length;
+      memcpy (&last_char->last_char, new_text, new_text_length);
+      last_char->last_char_position = *position + n_chars;
+    }
+  else
+    {
+      g_object_set_qdata (G_OBJECT (entry), quark_last_char, NULL);
     }
 
   *position += n_chars;
@@ -3112,7 +3133,6 @@ gtk_entry_create_layout (GtkEntry *entry
 			 gboolean  include_preedit)
 {
   GtkWidget *widget = GTK_WIDGET (entry);
-  GtkEntryPrivate *priv = GTK_ENTRY_GET_PRIVATE (entry);
   PangoLayout *layout = gtk_widget_create_pango_layout (widget, NULL);
   PangoAttrList *tmp_attrs = pango_attr_list_new ();
   
@@ -3222,6 +3242,7 @@ gtk_entry_create_layout (GtkEntry *entry
           GString *str = g_string_new (NULL);
           gunichar invisible_char;
           guint last_char_timeout;
+          GtkEntryLastChar *last_char;
 
           g_object_get (gtk_widget_get_settings (widget),
                         "gtk-entry-last-char-timeout", &last_char_timeout,
@@ -3232,39 +3253,42 @@ gtk_entry_create_layout (GtkEntry *entry
           else
             invisible_char = ' '; /* just pick a char */
 
-          if (priv->last_char_timeout_id)
+          last_char = g_object_get_qdata (G_OBJECT (entry), quark_last_char);
+
+          if (last_char && last_char->last_char_timeout_id)
             {
-              g_source_remove (priv->last_char_timeout_id);
-              priv->last_char_timeout_id = 0;
+              g_source_remove (last_char->last_char_timeout_id);
+              last_char->last_char_timeout_id = 0;
             }
 
-          if (last_char_timeout == 0 || priv->last_char_length == 0)
+          if (last_char_timeout == 0 || last_char == NULL ||
+              (last_char && last_char->last_char_length == 0))
             {
               append_char (str, invisible_char, entry->text_length);
             }
-          else
+          else if (last_char)
             {
               /* Draw hidden characters upto the inserted position,
                * then the real thing, pad up to full length
                */
-              if (priv->last_char_position > 1)
+              if (last_char->last_char_position > 1)
                 append_char (str, invisible_char,
-                             priv->last_char_position - 1);
+                             last_char->last_char_position - 1);
 
-              g_string_append_len (str, priv->last_char,
-                                   priv->last_char_length);
+              g_string_append_len (str, last_char->last_char,
+                                   last_char->last_char_length);
 
-              if (priv->last_char_position < entry->text_length)
+              if (last_char->last_char_position < entry->text_length)
                 append_char (str, invisible_char,
-                             entry->text_length - priv->last_char_position);
+                             entry->text_length - last_char->last_char_position);
 
               /* Now remove this last inputted character, don't need
                * it anymore
                */
-              memset (priv->last_char, 0, LAST_CHAR_MAX);
-              priv->last_char_length = 0;
+              memset (last_char->last_char, 0, LAST_CHAR_MAX);
+              last_char->last_char_length = 0;
 
-              priv->last_char_timeout_id =
+              last_char->last_char_timeout_id =
                 g_timeout_add (last_char_timeout,
                                (GSourceFunc) gtk_entry_remove_last_char,
                                entry);
