]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkentry.c
Minor documentation improvements
[~andy/gtk] / gtk / gtkentry.c
index 9aedc510611d218d1f6126dafa2aac5d694a9093..4dacb7d83c78f5724749348c823bafa25d2fb2b3 100644 (file)
@@ -1,6 +1,9 @@
 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* GTK - The GIMP Toolkit
  * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
+ * Copyright (C) 2004-2006 Christian Hammond
+ * Copyright (C) 2008 Cody Russell
+ * Copyright (C) 2008 Red Hat, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  */
 
 #include "config.h"
+
+#include <math.h>
 #include <string.h>
 
-#include "gdk/gdkkeysyms.h"
 #include "gtkalignment.h"
 #include "gtkbindings.h"
 #include "gtkcelleditable.h"
 #include "gtkclipboard.h"
 #include "gtkdnd.h"
 #include "gtkentry.h"
+#include "gtkentrybuffer.h"
 #include "gtkimagemenuitem.h"
 #include "gtkimcontextsimple.h"
 #include "gtkimmulticontext.h"
 #include "gtkwindow.h"
 #include "gtktreeview.h"
 #include "gtktreeselection.h"
+#include "gtktypebuiltins.h"
 #include "gtkprivate.h"
 #include "gtkentryprivate.h"
 #include "gtkcelllayout.h"
-#include "gtkalias.h"
+#include "gtktooltip.h"
+#include "gtkiconfactory.h"
+#include "gtkicontheme.h"
+#include "gtkwidgetprivate.h"
+#include "gtkstylecontextprivate.h"
+
+/**
+ * SECTION:gtkentry
+ * @Short_description: A single line text entry field
+ * @Title: GtkEntry
+ * @See_also: #GtkTextView, #GtkEntryCompletion
+ *
+ * The #GtkEntry widget is a single line text entry
+ * widget. A fairly large set of key bindings are supported
+ * by default. If the entered text is longer than the allocation
+ * of the widget, the widget will scroll so that the cursor
+ * position is visible.
+ *
+ * When using an entry for passwords and other sensitive information,
+ * it can be put into "password mode" using gtk_entry_set_visibility().
+ * In this mode, entered text is displayed using a 'invisible' character.
+ * By default, GTK+ picks the best invisible character that is available
+ * in the current font, but it can be changed with
+ * gtk_entry_set_invisible_char(). Since 2.16, GTK+ displays a warning
+ * when Caps Lock or input methods might interfere with entering text in
+ * a password entry. The warning can be turned off with the
+ * #GtkEntry:caps-lock-warning property.
+ *
+ * Since 2.16, GtkEntry has the ability to display progress or activity
+ * information behind the text. To make an entry display such information,
+ * use gtk_entry_set_progress_fraction() or gtk_entry_set_progress_pulse_step().
+ *
+ * Additionally, GtkEntry can show icons at either side of the entry. These
+ * icons can be activatable by clicking, can be set up as drag source and
+ * can have tooltips. To add an icon, use gtk_entry_set_icon_from_gicon() or
+ * one of the various other functions that set an icon from a stock id, an
+ * icon name or a pixbuf. To trigger an action when the user clicks an icon,
+ * connect to the #GtkEntry::icon-press signal. To allow DND operations
+ * from an icon, use gtk_entry_set_icon_drag_source(). To set a tooltip on
+ * an icon, use gtk_entry_set_icon_tooltip_text() or the corresponding function
+ * for markup.
+ *
+ * Note that functionality or information that is only available by clicking
+ * on an icon in an entry may not be accessible at all to users which are not
+ * able to use a mouse or other pointing device. It is therefore recommended
+ * that any such functionality should also be available by other means, e.g.
+ * via the context menu of the entry.
+ */
+
 
 #define GTK_ENTRY_COMPLETION_KEY "gtk-entry-completion-key"
 
 #define COMPLETION_TIMEOUT 300
 #define PASSWORD_HINT_MAX 8
 
-/* Initial size of buffer, in bytes */
-#define MIN_SIZE 16
+#define MAX_ICONS 2
 
-/* Maximum size of text buffer, in bytes */
-#define MAX_SIZE G_MAXUSHORT
+#define IS_VALID_ICON_POSITION(pos)               \
+  ((pos) == GTK_ENTRY_ICON_PRIMARY ||                   \
+   (pos) == GTK_ENTRY_ICON_SECONDARY)
 
 static const GtkBorder default_inner_border = { 2, 2, 2, 2 };
 static GQuark          quark_inner_border   = 0;
@@ -77,37 +131,114 @@ static GQuark          quark_password_hint  = 0;
 static GQuark          quark_cursor_hadjustment = 0;
 static GQuark          quark_capslock_feedback = 0;
 
-typedef struct _GtkEntryPrivate GtkEntryPrivate;
+typedef struct _EntryIconInfo EntryIconInfo;
+typedef struct _GtkEntryPasswordHint GtkEntryPasswordHint;
+typedef struct _GtkEntryCapslockFeedback GtkEntryCapslockFeedback;
 
-#define GTK_ENTRY_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_ENTRY, GtkEntryPrivate))
+struct _GtkEntryPrivate
+{
+  EntryIconInfo         *icons[MAX_ICONS];
+
+  GtkEntryBuffer        *buffer;
+  GtkIMContext          *im_context;
+  GtkShadowType          shadow_type;
+  GtkWidget             *popup_menu;
+
+  GdkDevice             *completion_device;
+  GdkWindow             *text_area;
+
+  PangoLayout           *cached_layout;
+
+  gchar        *im_module;
+
+  gdouble       progress_fraction;
+  gdouble       progress_pulse_fraction;
+  gdouble       progress_pulse_current;
+
+  gfloat        xalign;
+
+  gint          ascent;                     /* font ascent in pango units  */
+  gint          current_pos;
+  gint          descent;                    /* font descent in pango units */
+  gint          dnd_position;               /* In chars, -1 == no DND cursor */
+  gint          drag_start_x;
+  gint          drag_start_y;
+  gint          focus_width;
+  gint          icon_margin;
+  gint          insert_pos;
+  gint          selection_bound;
+  gint          scroll_offset;
+  gint          start_x;
+  gint          start_y;
+  gint          width_chars;
+
+  gunichar      invisible_char;
+
+  guint         button;
+  guint         blink_time;                  /* time in msec the cursor has blinked since last user event */
+  guint         blink_timeout;
+  guint         recompute_idle;
+
+  guint16       x_text_size;                 /* allocated size, in bytes */
+  guint16       x_n_bytes;                   /* length in use, in bytes */
+
+  guint16       preedit_length;              /* length of preedit string, in bytes */
+  guint16      preedit_cursor;              /* offset of cursor within preedit string, in chars */
+
+  guint         editable                : 1;
+  guint         in_drag                 : 1;
+  guint         overwrite_mode          : 1;
+  guint         visible                 : 1;
+
+  guint         activates_default       : 1;
+  guint         cache_includes_preedit  : 1;
+  guint         caps_lock_warning       : 1;
+  guint         caps_lock_warning_shown : 1;
+  guint         change_count            : 8;
+  guint         cursor_visible          : 1;
+  guint         editing_canceled        : 1; /* Only used by GtkCellRendererText */
+  guint         has_frame               : 1;
+  guint         in_click                : 1; /* Flag so we don't select all when clicking in entry to focus in */
+  guint         is_cell_renderer        : 1;
+  guint         invisible_char_set      : 1;
+  guint         interior_focus          : 1;
+  guint         mouse_cursor_obscured   : 1;
+  guint         need_im_reset           : 1;
+  guint         progress_pulse_mode     : 1;
+  guint         progress_pulse_way_back : 1;
+  guint         real_changed            : 1;
+  guint         resolved_dir            : 4; /* PangoDirection */
+  guint         select_words            : 1;
+  guint         select_lines            : 1;
+  guint         truncate_multiline      : 1;
+};
 
-struct _GtkEntryPrivate 
+struct _EntryIconInfo
 {
-  gfloat xalign;
-  gint insert_pos;
-  guint blink_time;  /* time in msec the cursor has blinked since last user event */
-  guint interior_focus : 1;
-  guint real_changed   : 1;
-  guint invisible_char_set : 1;
-  guint caps_lock_warning : 1;
-  guint change_count   : 8;
+  GdkWindow *window;
+  gchar *tooltip;
+  guint insensitive    : 1;
+  guint nonactivatable : 1;
+  guint prelight       : 1;
+  guint in_drag        : 1;
+  guint pressed        : 1;
 
-  gint focus_width;
-  GtkShadowType shadow_type;
-};
+  GtkImageType  storage_type;
+  GdkPixbuf    *pixbuf;
+  gchar        *stock_id;
+  gchar        *icon_name;
+  GIcon        *gicon;
 
-typedef struct _GtkEntryPasswordHint GtkEntryPasswordHint;
+  GtkTargetList *target_list;
+  GdkDragAction actions;
+};
 
 struct _GtkEntryPasswordHint
 {
-  gchar password_hint[PASSWORD_HINT_MAX];
-  guint password_hint_timeout_id;
-  gint  password_hint_length;
-  gint  password_hint_position;
+  gint position;      /* Position (in text) of the last password hint */
+  guint source_id;    /* Timeout source id */
 };
 
-typedef struct _GtkEntryCapslockFeedback GtkEntryCapslockFeedback;
-
 struct _GtkEntryCapslockFeedback
 {
   GtkWidget *entry;
@@ -126,11 +257,15 @@ enum {
   COPY_CLIPBOARD,
   PASTE_CLIPBOARD,
   TOGGLE_OVERWRITE,
+  ICON_PRESS,
+  ICON_RELEASE,
+  PREEDIT_CHANGED,
   LAST_SIGNAL
 };
 
 enum {
   PROP_0,
+  PROP_BUFFER,
   PROP_CURSOR_POSITION,
   PROP_SELECTION_BOUND,
   PROP_EDITABLE,
@@ -149,7 +284,29 @@ enum {
   PROP_OVERWRITE_MODE,
   PROP_TEXT_LENGTH,
   PROP_INVISIBLE_CHAR_SET,
-  PROP_CAPS_LOCK_WARNING
+  PROP_CAPS_LOCK_WARNING,
+  PROP_PROGRESS_FRACTION,
+  PROP_PROGRESS_PULSE_STEP,
+  PROP_PIXBUF_PRIMARY,
+  PROP_PIXBUF_SECONDARY,
+  PROP_STOCK_PRIMARY,
+  PROP_STOCK_SECONDARY,
+  PROP_ICON_NAME_PRIMARY,
+  PROP_ICON_NAME_SECONDARY,
+  PROP_GICON_PRIMARY,
+  PROP_GICON_SECONDARY,
+  PROP_STORAGE_TYPE_PRIMARY,
+  PROP_STORAGE_TYPE_SECONDARY,
+  PROP_ACTIVATABLE_PRIMARY,
+  PROP_ACTIVATABLE_SECONDARY,
+  PROP_SENSITIVE_PRIMARY,
+  PROP_SENSITIVE_SECONDARY,
+  PROP_TOOLTIP_TEXT_PRIMARY,
+  PROP_TOOLTIP_TEXT_SECONDARY,
+  PROP_TOOLTIP_MARKUP_PRIMARY,
+  PROP_TOOLTIP_MARKUP_SECONDARY,
+  PROP_IM_MODULE,
+  PROP_EDITING_CANCELED
 };
 
 static guint signals[LAST_SIGNAL] = { 0 };
@@ -159,9 +316,16 @@ typedef enum {
   CURSOR_DND
 } CursorType;
 
-/* GObject, GtkObject methods
+typedef enum
+{
+  DISPLAY_NORMAL,       /* The entry text is being shown */
+  DISPLAY_INVISIBLE,    /* In invisible mode, text replaced by (eg) bullets */
+  DISPLAY_BLANK         /* In invisible mode, nothing shown at all */
+} DisplayMode;
+
+/* GObject methods
  */
-static void   gtk_entry_editable_init        (GtkEditableClass     *iface);
+static void   gtk_entry_editable_init        (GtkEditableInterface *iface);
 static void   gtk_entry_cell_editable_init   (GtkCellEditableIface *iface);
 static void   gtk_entry_set_property         (GObject          *object,
                                               guint             prop_id,
@@ -172,24 +336,39 @@ static void   gtk_entry_get_property         (GObject          *object,
                                               GValue           *value,
                                               GParamSpec       *pspec);
 static void   gtk_entry_finalize             (GObject          *object);
-static void   gtk_entry_destroy              (GtkObject        *object);
+static void   gtk_entry_dispose              (GObject          *object);
 
 /* GtkWidget methods
  */
+static void   gtk_entry_destroy              (GtkWidget        *widget);
 static void   gtk_entry_realize              (GtkWidget        *widget);
 static void   gtk_entry_unrealize            (GtkWidget        *widget);
-static void   gtk_entry_size_request         (GtkWidget        *widget,
-                                             GtkRequisition   *requisition);
+static void   gtk_entry_map                  (GtkWidget        *widget);
+static void   gtk_entry_unmap                (GtkWidget        *widget);
+static void   gtk_entry_get_preferred_width  (GtkWidget        *widget,
+                                              gint             *minimum,
+                                              gint             *natural);
+static void   gtk_entry_get_preferred_height (GtkWidget        *widget,
+                                              gint             *minimum,
+                                              gint             *natural);
 static void   gtk_entry_size_allocate        (GtkWidget        *widget,
                                              GtkAllocation    *allocation);
 static void   gtk_entry_draw_frame           (GtkWidget        *widget,
-                                              GdkRectangle     *area);
-static gint   gtk_entry_expose               (GtkWidget        *widget,
-                                             GdkEventExpose   *event);
+                                              GtkStyleContext  *context,
+                                              cairo_t          *cr);
+static void   gtk_entry_draw_progress        (GtkWidget        *widget,
+                                              GtkStyleContext  *context,
+                                              cairo_t          *cr);
+static gint   gtk_entry_draw                 (GtkWidget        *widget,
+                                              cairo_t          *cr);
 static gint   gtk_entry_button_press         (GtkWidget        *widget,
                                              GdkEventButton   *event);
 static gint   gtk_entry_button_release       (GtkWidget        *widget,
                                              GdkEventButton   *event);
+static gint   gtk_entry_enter_notify         (GtkWidget        *widget,
+                                              GdkEventCrossing *event);
+static gint   gtk_entry_leave_notify         (GtkWidget        *widget,
+                                              GdkEventCrossing *event);
 static gint   gtk_entry_motion_notify        (GtkWidget        *widget,
                                              GdkEventMotion   *event);
 static gint   gtk_entry_key_press            (GtkWidget        *widget,
@@ -201,12 +380,16 @@ static gint   gtk_entry_focus_in             (GtkWidget        *widget,
 static gint   gtk_entry_focus_out            (GtkWidget        *widget,
                                              GdkEventFocus    *event);
 static void   gtk_entry_grab_focus           (GtkWidget        *widget);
-static void   gtk_entry_style_set            (GtkWidget        *widget,
-                                             GtkStyle         *previous_style);
+static void   gtk_entry_style_updated        (GtkWidget        *widget);
+static gboolean gtk_entry_query_tooltip      (GtkWidget        *widget,
+                                              gint              x,
+                                              gint              y,
+                                              gboolean          keyboard_tip,
+                                              GtkTooltip       *tooltip);
 static void   gtk_entry_direction_changed    (GtkWidget        *widget,
                                              GtkTextDirection  previous_dir);
-static void   gtk_entry_state_changed        (GtkWidget        *widget,
-                                             GtkStateType      previous_state);
+static void   gtk_entry_state_flags_changed  (GtkWidget        *widget,
+                                             GtkStateFlags     previous_state);
 static void   gtk_entry_screen_changed       (GtkWidget        *widget,
                                              GdkScreen        *old_screen);
 
@@ -237,6 +420,11 @@ static void     gtk_entry_drag_data_get      (GtkWidget        *widget,
                                              guint             time);
 static void     gtk_entry_drag_data_delete   (GtkWidget        *widget,
                                              GdkDragContext   *context);
+static void     gtk_entry_drag_begin         (GtkWidget        *widget,
+                                              GdkDragContext   *context);
+static void     gtk_entry_drag_end           (GtkWidget        *widget,
+                                              GdkDragContext   *context);
+
 
 /* GtkEditable method implementations
  */
@@ -319,13 +507,14 @@ static void         gtk_entry_enter_text               (GtkEntry       *entry,
 static void         gtk_entry_set_positions            (GtkEntry       *entry,
                                                        gint            current_pos,
                                                        gint            selection_bound);
-static void         gtk_entry_draw_text                (GtkEntry       *entry);
+static void         gtk_entry_draw_text                (GtkEntry       *entry,
+                                                        cairo_t        *cr);
 static void         gtk_entry_draw_cursor              (GtkEntry       *entry,
+                                                        cairo_t        *cr,
                                                        CursorType      type);
 static PangoLayout *gtk_entry_ensure_layout            (GtkEntry       *entry,
                                                         gboolean        include_preedit);
 static void         gtk_entry_reset_layout             (GtkEntry       *entry);
-static void         gtk_entry_queue_draw               (GtkEntry       *entry);
 static void         gtk_entry_recompute                (GtkEntry       *entry);
 static gint         gtk_entry_find_position            (GtkEntry       *entry,
                                                        gint            x);
@@ -349,9 +538,6 @@ static gint         gtk_entry_move_backward_word       (GtkEntry       *entry,
 static void         gtk_entry_delete_whitespace        (GtkEntry       *entry);
 static void         gtk_entry_select_word              (GtkEntry       *entry);
 static void         gtk_entry_select_line              (GtkEntry       *entry);
-static char *       gtk_entry_get_public_chars         (GtkEntry       *entry,
-                                                       gint            start,
-                                                       gint            end);
 static void         gtk_entry_paste                    (GtkEntry       *entry,
                                                        GdkAtom         selection);
 static void         gtk_entry_update_primary_selection (GtkEntry       *entry);
@@ -359,27 +545,28 @@ static void         gtk_entry_do_popup                 (GtkEntry       *entry,
                                                        GdkEventButton *event);
 static gboolean     gtk_entry_mnemonic_activate        (GtkWidget      *widget,
                                                        gboolean        group_cycling);
-static void         gtk_entry_state_changed            (GtkWidget      *widget,
-                                                       GtkStateType    previous_state);
 static void         gtk_entry_check_cursor_blink       (GtkEntry       *entry);
 static void         gtk_entry_pend_cursor_blink        (GtkEntry       *entry);
 static void         gtk_entry_reset_blink_time         (GtkEntry       *entry);
-static void         get_text_area_size                 (GtkEntry       *entry,
+static void         gtk_entry_get_text_area_size       (GtkEntry       *entry,
                                                        gint           *x,
                                                        gint           *y,
                                                        gint           *width,
                                                        gint           *height);
-static void         gtk_entry_get_text_area_size       (GtkEntry       *entry,
+static void         get_text_area_size                 (GtkEntry       *entry,
                                                        gint           *x,
                                                        gint           *y,
                                                        gint           *width,
                                                        gint           *height);
-static void         get_widget_window_size             (GtkEntry       *entry,
+static void         get_frame_size                     (GtkEntry       *entry,
                                                        gint           *x,
                                                        gint           *y,
                                                        gint           *width,
                                                        gint           *height);
-static void         gtk_entry_move_adjustments         (GtkEntry       *entry);
+static void         gtk_entry_move_adjustments         (GtkEntry             *entry);
+static void         gtk_entry_ensure_pixbuf            (GtkEntry             *entry,
+                                                        GtkEntryIconPosition  icon_pos);
+
 
 /* Completion */
 static gint         gtk_entry_completion_timeout       (gpointer            data);
@@ -410,6 +597,29 @@ static void         end_change                         (GtkEntry *entry);
 static void         emit_changed                       (GtkEntry *entry);
 
 
+static void         buffer_inserted_text               (GtkEntryBuffer *buffer, 
+                                                        guint           position,
+                                                        const gchar    *chars,
+                                                        guint           n_chars,
+                                                        GtkEntry       *entry);
+static void         buffer_deleted_text                (GtkEntryBuffer *buffer, 
+                                                        guint           position,
+                                                        guint           n_chars,
+                                                        GtkEntry       *entry);
+static void         buffer_notify_text                 (GtkEntryBuffer *buffer, 
+                                                        GParamSpec     *spec,
+                                                        GtkEntry       *entry);
+static void         buffer_notify_length               (GtkEntryBuffer *buffer, 
+                                                        GParamSpec     *spec,
+                                                        GtkEntry       *entry);
+static void         buffer_notify_max_length           (GtkEntryBuffer *buffer, 
+                                                        GParamSpec     *spec,
+                                                        GtkEntry       *entry);
+static void         buffer_connect_signals             (GtkEntry       *entry);
+static void         buffer_disconnect_signals          (GtkEntry       *entry);
+static GtkEntryBuffer *get_buffer                      (GtkEntry       *entry);
+
+
 G_DEFINE_TYPE_WITH_CODE (GtkEntry, gtk_entry, GTK_TYPE_WIDGET,
                          G_IMPLEMENT_INTERFACE (GTK_TYPE_EDITABLE,
                                                 gtk_entry_editable_init)
@@ -444,21 +654,26 @@ gtk_entry_class_init (GtkEntryClass *class)
 {
   GObjectClass *gobject_class = G_OBJECT_CLASS (class);
   GtkWidgetClass *widget_class;
-  GtkObjectClass *gtk_object_class;
   GtkBindingSet *binding_set;
 
   widget_class = (GtkWidgetClass*) class;
-  gtk_object_class = (GtkObjectClass *)class;
 
+  gobject_class->dispose = gtk_entry_dispose;
   gobject_class->finalize = gtk_entry_finalize;
   gobject_class->set_property = gtk_entry_set_property;
   gobject_class->get_property = gtk_entry_get_property;
 
+  widget_class->destroy = gtk_entry_destroy;
+  widget_class->map = gtk_entry_map;
+  widget_class->unmap = gtk_entry_unmap;
   widget_class->realize = gtk_entry_realize;
   widget_class->unrealize = gtk_entry_unrealize;
-  widget_class->size_request = gtk_entry_size_request;
+  widget_class->get_preferred_width = gtk_entry_get_preferred_width;
+  widget_class->get_preferred_height = gtk_entry_get_preferred_height;
   widget_class->size_allocate = gtk_entry_size_allocate;
-  widget_class->expose_event = gtk_entry_expose;
+  widget_class->draw = gtk_entry_draw;
+  widget_class->enter_notify_event = gtk_entry_enter_notify;
+  widget_class->leave_notify_event = gtk_entry_leave_notify;
   widget_class->button_press_event = gtk_entry_button_press;
   widget_class->button_release_event = gtk_entry_button_release;
   widget_class->motion_notify_event = gtk_entry_motion_notify;
@@ -467,9 +682,12 @@ gtk_entry_class_init (GtkEntryClass *class)
   widget_class->focus_in_event = gtk_entry_focus_in;
   widget_class->focus_out_event = gtk_entry_focus_out;
   widget_class->grab_focus = gtk_entry_grab_focus;
-  widget_class->style_set = gtk_entry_style_set;
+  widget_class->style_updated = gtk_entry_style_updated;
+  widget_class->query_tooltip = gtk_entry_query_tooltip;
+  widget_class->drag_begin = gtk_entry_drag_begin;
+  widget_class->drag_end = gtk_entry_drag_end;
   widget_class->direction_changed = gtk_entry_direction_changed;
-  widget_class->state_changed = gtk_entry_state_changed;
+  widget_class->state_flags_changed = gtk_entry_state_flags_changed;
   widget_class->screen_changed = gtk_entry_screen_changed;
   widget_class->mnemonic_activate = gtk_entry_mnemonic_activate;
 
@@ -482,8 +700,6 @@ gtk_entry_class_init (GtkEntryClass *class)
 
   widget_class->popup_menu = gtk_entry_popup_menu;
 
-  gtk_object_class->destroy = gtk_entry_destroy;
-
   class->move_cursor = gtk_entry_move_cursor;
   class->insert_at_cursor = gtk_entry_insert_at_cursor;
   class->delete_from_cursor = gtk_entry_delete_from_cursor;
@@ -500,13 +716,25 @@ gtk_entry_class_init (GtkEntryClass *class)
   quark_cursor_hadjustment = g_quark_from_static_string ("gtk-hadjustment");
   quark_capslock_feedback = g_quark_from_static_string ("gtk-entry-capslock-feedback");
 
+  g_object_class_override_property (gobject_class,
+                                    PROP_EDITING_CANCELED,
+                                    "editing-canceled");
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_BUFFER,
+                                   g_param_spec_object ("buffer",
+                                                        P_("Text Buffer"),
+                                                        P_("Text buffer object which actually stores entry text"),
+                                                        GTK_TYPE_ENTRY_BUFFER,
+                                                        GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
   g_object_class_install_property (gobject_class,
                                    PROP_CURSOR_POSITION,
                                    g_param_spec_int ("cursor-position",
                                                      P_("Cursor Position"),
                                                      P_("The current position of the insertion cursor in chars"),
                                                      0,
-                                                     MAX_SIZE,
+                                                     GTK_ENTRY_BUFFER_MAX_SIZE,
                                                      0,
                                                      GTK_PARAM_READABLE));
   
@@ -516,7 +744,7 @@ gtk_entry_class_init (GtkEntryClass *class)
                                                      P_("Selection Bound"),
                                                      P_("The position of the opposite end of the selection from the cursor in chars"),
                                                      0,
-                                                     MAX_SIZE,
+                                                     GTK_ENTRY_BUFFER_MAX_SIZE,
                                                      0,
                                                      GTK_PARAM_READABLE));
   
@@ -534,7 +762,7 @@ gtk_entry_class_init (GtkEntryClass *class)
                                                      P_("Maximum length"),
                                                      P_("Maximum number of characters for this entry. Zero if no maximum"),
                                                      0,
-                                                     MAX_SIZE,
+                                                     GTK_ENTRY_BUFFER_MAX_SIZE,
                                                      0,
                                                      GTK_PARAM_READWRITE));
   g_object_class_install_property (gobject_class,
@@ -668,6 +896,7 @@ gtk_entry_class_init (GtkEntryClass *class)
                                                          P_("Whether new text overwrites existing text"),
                                                          FALSE,
                                                          GTK_PARAM_READWRITE));
+
   /**
    * GtkEntry:text-length:
    *
@@ -694,18 +923,19 @@ gtk_entry_class_init (GtkEntryClass *class)
   g_object_class_install_property (gobject_class,
                                    PROP_INVISIBLE_CHAR_SET,
                                    g_param_spec_boolean ("invisible-char-set",
-                                                         P_("Invisible char set"),
-                                                         P_("Whether the invisible char has been set"),
+                                                         P_("Invisible character set"),
+                                                         P_("Whether the invisible character has been set"),
                                                          FALSE,
                                                          GTK_PARAM_READWRITE));
 
-
-
   /**
    * GtkEntry:caps-lock-warning
    *
-   * Whether password entries will show a warning when Caps Lock is on
-   * or an input method is active.
+   * Whether password entries will show a warning when Caps Lock is on.
+   *
+   * Note that the warning is shown using a secondary icon, and thus
+   * does not work if you are using the secondary icon position for some 
+   * other purpose.
    *
    * Since: 2.16
    */
@@ -713,11 +943,437 @@ gtk_entry_class_init (GtkEntryClass *class)
                                    PROP_CAPS_LOCK_WARNING,
                                    g_param_spec_boolean ("caps-lock-warning",
                                                          P_("Caps Lock warning"),
-                                                         P_("Whether password entries will show a warning when Caps Lock is on or an input method is active"),
+                                                         P_("Whether password entries will show a warning when Caps Lock is on"),
                                                          TRUE,
                                                          GTK_PARAM_READWRITE));
 
+  /**
+   * GtkEntry:progress-fraction:
+   *
+   * The current fraction of the task that's been completed.
+   *
+   * Since: 2.16
+   */
+  g_object_class_install_property (gobject_class,
+                                   PROP_PROGRESS_FRACTION,
+                                   g_param_spec_double ("progress-fraction",
+                                                        P_("Progress Fraction"),
+                                                        P_("The current fraction of the task that's been completed"),
+                                                        0.0,
+                                                        1.0,
+                                                        0.0,
+                                                        GTK_PARAM_READWRITE));
+
+  /**
+   * GtkEntry:progress-pulse-step:
+   *
+   * The fraction of total entry width to move the progress
+   * bouncing block for each call to gtk_entry_progress_pulse().
+   *
+   * Since: 2.16
+   */
+  g_object_class_install_property (gobject_class,
+                                   PROP_PROGRESS_PULSE_STEP,
+                                   g_param_spec_double ("progress-pulse-step",
+                                                        P_("Progress Pulse Step"),
+                                                        P_("The fraction of total entry width to move the progress bouncing block for each call to gtk_entry_progress_pulse()"),
+                                                        0.0,
+                                                        1.0,
+                                                        0.1,
+                                                        GTK_PARAM_READWRITE));
+
+  /**
+   * GtkEntry:primary-icon-pixbuf:
+   *
+   * A pixbuf to use as the primary icon for the entry.
+   *
+   * Since: 2.16
+   */
+  g_object_class_install_property (gobject_class,
+                                   PROP_PIXBUF_PRIMARY,
+                                   g_param_spec_object ("primary-icon-pixbuf",
+                                                        P_("Primary pixbuf"),
+                                                        P_("Primary pixbuf for the entry"),
+                                                        GDK_TYPE_PIXBUF,
+                                                        GTK_PARAM_READWRITE));
+  
+  /**
+   * GtkEntry:secondary-icon-pixbuf:
+   *
+   * An pixbuf to use as the secondary icon for the entry.
+   *
+   * Since: 2.16
+   */
+  g_object_class_install_property (gobject_class,
+                                   PROP_PIXBUF_SECONDARY,
+                                   g_param_spec_object ("secondary-icon-pixbuf",
+                                                        P_("Secondary pixbuf"),
+                                                        P_("Secondary pixbuf for the entry"),
+                                                        GDK_TYPE_PIXBUF,
+                                                        GTK_PARAM_READWRITE));
+
+  /**
+   * GtkEntry:primary-icon-stock:
+   *
+   * The stock id to use for the primary icon for the entry.
+   *
+   * Since: 2.16
+   */
+  g_object_class_install_property (gobject_class,
+                                   PROP_STOCK_PRIMARY,
+                                   g_param_spec_string ("primary-icon-stock",
+                                                        P_("Primary stock ID"),
+                                                        P_("Stock ID for primary icon"),
+                                                        NULL,
+                                                        GTK_PARAM_READWRITE));
+
+  /**
+   * GtkEntry:secondary-icon-stock:
+   *
+   * The stock id to use for the secondary icon for the entry.
+   *
+   * Since: 2.16
+   */
+  g_object_class_install_property (gobject_class,
+                                   PROP_STOCK_SECONDARY,
+                                   g_param_spec_string ("secondary-icon-stock",
+                                                        P_("Secondary stock ID"),
+                                                        P_("Stock ID for secondary icon"),
+                                                        NULL,
+                                                        GTK_PARAM_READWRITE));
+  
+  /**
+   * GtkEntry:primary-icon-name:
+   *
+   * The icon name to use for the primary icon for the entry.
+   *
+   * Since: 2.16
+   */
+  g_object_class_install_property (gobject_class,
+                                   PROP_ICON_NAME_PRIMARY,
+                                   g_param_spec_string ("primary-icon-name",
+                                                        P_("Primary icon name"),
+                                                        P_("Icon name for primary icon"),
+                                                        NULL,
+                                                        GTK_PARAM_READWRITE));
+  
+  /**
+   * GtkEntry:secondary-icon-name:
+   *
+   * The icon name to use for the secondary icon for the entry.
+   *
+   * Since: 2.16
+   */
+  g_object_class_install_property (gobject_class,
+                                   PROP_ICON_NAME_SECONDARY,
+                                   g_param_spec_string ("secondary-icon-name",
+                                                        P_("Secondary icon name"),
+                                                        P_("Icon name for secondary icon"),
+                                                        NULL,
+                                                        GTK_PARAM_READWRITE));
+  
+  /**
+   * GtkEntry:primary-icon-gicon:
+   *
+   * The #GIcon to use for the primary icon for the entry.
+   *
+   * Since: 2.16
+   */
+  g_object_class_install_property (gobject_class,
+                                   PROP_GICON_PRIMARY,
+                                   g_param_spec_object ("primary-icon-gicon",
+                                                        P_("Primary GIcon"),
+                                                        P_("GIcon for primary icon"),
+                                                        G_TYPE_ICON,
+                                                        GTK_PARAM_READWRITE));
+  
+  /**
+   * GtkEntry:secondary-icon-gicon:
+   *
+   * The #GIcon to use for the secondary icon for the entry.
+   *
+   * Since: 2.16
+   */
+  g_object_class_install_property (gobject_class,
+                                   PROP_GICON_SECONDARY,
+                                   g_param_spec_object ("secondary-icon-gicon",
+                                                        P_("Secondary GIcon"),
+                                                        P_("GIcon for secondary icon"),
+                                                        G_TYPE_ICON,
+                                                        GTK_PARAM_READWRITE));
+  
+  /**
+   * GtkEntry:primary-icon-storage-type:
+   *
+   * The representation which is used for the primary icon of the entry.
+   *
+   * Since: 2.16
+   */
+  g_object_class_install_property (gobject_class,
+                                   PROP_STORAGE_TYPE_PRIMARY,
+                                   g_param_spec_enum ("primary-icon-storage-type",
+                                                      P_("Primary storage type"),
+                                                      P_("The representation being used for primary icon"),
+                                                      GTK_TYPE_IMAGE_TYPE,
+                                                      GTK_IMAGE_EMPTY,
+                                                      GTK_PARAM_READABLE));
+  
+  /**
+   * GtkEntry:secondary-icon-storage-type:
+   *
+   * The representation which is used for the secondary icon of the entry.
+   *
+   * Since: 2.16
+   */
+  g_object_class_install_property (gobject_class,
+                                   PROP_STORAGE_TYPE_SECONDARY,
+                                   g_param_spec_enum ("secondary-icon-storage-type",
+                                                      P_("Secondary storage type"),
+                                                      P_("The representation being used for secondary icon"),
+                                                      GTK_TYPE_IMAGE_TYPE,
+                                                      GTK_IMAGE_EMPTY,
+                                                      GTK_PARAM_READABLE));
+  
+  /**
+   * GtkEntry:primary-icon-activatable:
+   *
+   * Whether the primary icon is activatable.
+   *
+   * GTK+ emits the #GtkEntry::icon-press and #GtkEntry::icon-release 
+   * signals only on sensitive, activatable icons. 
+   *
+   * Sensitive, but non-activatable icons can be used for purely 
+   * informational purposes.
+   *
+   * Since: 2.16
+   */
+  g_object_class_install_property (gobject_class,
+                                   PROP_ACTIVATABLE_PRIMARY,
+                                   g_param_spec_boolean ("primary-icon-activatable",
+                                                         P_("Primary icon activatable"),
+                                                         P_("Whether the primary icon is activatable"),
+                                                         TRUE,
+                                                         GTK_PARAM_READWRITE));
+  
+  /**
+   * GtkEntry:secondary-icon-activatable:
+   *
+   * Whether the secondary icon is activatable.
+   *
+   * GTK+ emits the #GtkEntry::icon-press and #GtkEntry::icon-release 
+   * signals only on sensitive, activatable icons.
+   *
+   * Sensitive, but non-activatable icons can be used for purely 
+   * informational purposes.
+   *
+   * Since: 2.16
+   */
+  g_object_class_install_property (gobject_class,
+                                   PROP_ACTIVATABLE_SECONDARY,
+                                   g_param_spec_boolean ("secondary-icon-activatable",
+                                                         P_("Secondary icon activatable"),
+                                                         P_("Whether the secondary icon is activatable"),
+                                                         TRUE,
+                                                         GTK_PARAM_READWRITE));
+  
+  
+  /**
+   * GtkEntry:primary-icon-sensitive:
+   *
+   * Whether the primary icon is sensitive.
+   *
+   * An insensitive icon appears grayed out. GTK+ does not emit the 
+   * #GtkEntry::icon-press and #GtkEntry::icon-release signals and 
+   * does not allow DND from insensitive icons.
+   *
+   * An icon should be set insensitive if the action that would trigger
+   * when clicked is currently not available.
+   * 
+   * Since: 2.16
+   */
+  g_object_class_install_property (gobject_class,
+                                   PROP_SENSITIVE_PRIMARY,
+                                   g_param_spec_boolean ("primary-icon-sensitive",
+                                                         P_("Primary icon sensitive"),
+                                                         P_("Whether the primary icon is sensitive"),
+                                                         TRUE,
+                                                         GTK_PARAM_READWRITE));
+  
+  /**
+   * GtkEntry:secondary-icon-sensitive:
+   *
+   * Whether the secondary icon is sensitive.
+   *
+   * An insensitive icon appears grayed out. GTK+ does not emit the 
+   * #GtkEntry::icon-press and #GtkEntry::icon-release signals and 
+   * does not allow DND from insensitive icons.
+   *
+   * An icon should be set insensitive if the action that would trigger
+   * when clicked is currently not available.
+   *
+   * Since: 2.16
+   */
+  g_object_class_install_property (gobject_class,
+                                   PROP_SENSITIVE_SECONDARY,
+                                   g_param_spec_boolean ("secondary-icon-sensitive",
+                                                         P_("Secondary icon sensitive"),
+                                                         P_("Whether the secondary icon is sensitive"),
+                                                         TRUE,
+                                                         GTK_PARAM_READWRITE));
+  
+  /**
+   * GtkEntry:primary-icon-tooltip-text:
+   * 
+   * The contents of the tooltip on the primary icon.
+   *
+   * Also see gtk_entry_set_icon_tooltip_text().
+   *
+   * Since: 2.16
+   */
+  g_object_class_install_property (gobject_class,
+                                   PROP_TOOLTIP_TEXT_PRIMARY,
+                                   g_param_spec_string ("primary-icon-tooltip-text",
+                                                        P_("Primary icon tooltip text"),
+                                                        P_("The contents of the tooltip on the primary icon"),                              
+                                                        NULL,
+                                                        GTK_PARAM_READWRITE));
+  
+  /**
+   * GtkEntry:secondary-icon-tooltip-text:
+   * 
+   * The contents of the tooltip on the secondary icon.
+   *
+   * Also see gtk_entry_set_icon_tooltip_text().
+   *
+   * Since: 2.16
+   */
+  g_object_class_install_property (gobject_class,
+                                   PROP_TOOLTIP_TEXT_SECONDARY,
+                                   g_param_spec_string ("secondary-icon-tooltip-text",
+                                                        P_("Secondary icon tooltip text"),
+                                                        P_("The contents of the tooltip on the secondary icon"),                              
+                                                        NULL,
+                                                        GTK_PARAM_READWRITE));
+
+  /**
+   * GtkEntry:primary-icon-tooltip-markup:
+   * 
+   * The contents of the tooltip on the primary icon, which is marked up
+   * with the <link linkend="PangoMarkupFormat">Pango text markup 
+   * language</link>.
+   *
+   * Also see gtk_entry_set_icon_tooltip_markup().
+   *
+   * Since: 2.16
+   */
+  g_object_class_install_property (gobject_class,
+                                   PROP_TOOLTIP_MARKUP_PRIMARY,
+                                   g_param_spec_string ("primary-icon-tooltip-markup",
+                                                        P_("Primary icon tooltip markup"),
+                                                        P_("The contents of the tooltip on the primary icon"),                              
+                                                        NULL,
+                                                        GTK_PARAM_READWRITE));
+
+  /**
+   * GtkEntry:secondary-icon-tooltip-markup:
+   * 
+   * The contents of the tooltip on the secondary icon, which is marked up
+   * with the <link linkend="PangoMarkupFormat">Pango text markup 
+   * language</link>.
+   *
+   * Also see gtk_entry_set_icon_tooltip_markup().
+   *
+   * Since: 2.16
+   */
+  g_object_class_install_property (gobject_class,
+                                   PROP_TOOLTIP_MARKUP_SECONDARY,
+                                   g_param_spec_string ("secondary-icon-tooltip-markup",
+                                                        P_("Secondary icon tooltip markup"),
+                                                        P_("The contents of the tooltip on the secondary icon"),                              
+                                                        NULL,
+                                                        GTK_PARAM_READWRITE));
+
+  /**
+   * GtkEntry:im-module:
+   *
+   * Which IM (input method) module should be used for this entry. 
+   * See #GtkIMContext.
+   * 
+   * Setting this to a non-%NULL value overrides the
+   * system-wide IM module setting. See the GtkSettings 
+   * #GtkSettings:gtk-im-module property.
+   *
+   * Since: 2.16
+   */  
+  g_object_class_install_property (gobject_class,
+                                   PROP_IM_MODULE,
+                                   g_param_spec_string ("im-module",
+                                                        P_("IM module"),
+                                                        P_("Which IM module should be used"),
+                                                        NULL,
+                                                        GTK_PARAM_READWRITE));
+
+  /**
+   * GtkEntry:icon-prelight:
+   *
+   * The prelight style property determines whether activatable
+   * icons prelight on mouseover.
+   *
+   * Since: 2.16
+   */
+  gtk_widget_class_install_style_property (widget_class,
+                                           g_param_spec_boolean ("icon-prelight",
+                                                                 P_("Icon Prelight"),
+                                                                 P_("Whether activatable icons should prelight when hovered"),
+                                                                 TRUE,
+                                                                 GTK_PARAM_READABLE));
+
+  /**
+   * GtkEntry:progress-border:
+   *
+   * The border around the progress bar in the entry.
+   *
+   * Since: 2.16
+   */
+  gtk_widget_class_install_style_property (widget_class,
+                                          g_param_spec_boxed ("progress-border",
+                                                               P_("Progress Border"),
+                                                               P_("Border around the progress bar"),
+                                                               GTK_TYPE_BORDER,
+                                                               GTK_PARAM_READABLE));
+  
+  /**
+   * GtkEntry:invisible-char:
+   *
+   * The invisible character is used when masking entry contents (in
+   * \"password mode\")"). When it is not explicitly set with the
+   * #GtkEntry::invisible-char property, GTK+ determines the character
+   * to use from a list of possible candidates, depending on availability
+   * in the current font.
+   *
+   * This style property allows the theme to prepend a character
+   * to the list of candidates.
+   *
+   * Since: 2.18
+   */
+  gtk_widget_class_install_style_property (widget_class,
+                                           g_param_spec_unichar ("invisible-char",
+                                                                P_("Invisible character"),
+                                                                P_("The character to use when masking entry contents (in \"password mode\")"),
+                                                                0,
+                                                                GTK_PARAM_READABLE));
+  
+  /**
+   * GtkEntry::populate-popup:
+   * @entry: The entry on which the signal is emitted
+   * @menu: the menu that is being populated
+   *
+   * The ::populate-popup signal gets emitted before showing the 
+   * context menu of the entry. 
+   *
+   * If you need to add items to the context menu, connect
+   * to this signal and append your menuitems to the @menu.
+   */
   signals[POPULATE_POPUP] =
     g_signal_new (I_("populate-popup"),
                  G_OBJECT_CLASS_TYPE (gobject_class),
@@ -730,6 +1386,19 @@ gtk_entry_class_init (GtkEntryClass *class)
   
  /* Action signals */
   
+  /**
+   * GtkEntry::activate:
+   * @entry: The entry on which the signal is emitted
+   *
+   * A  <link linkend="keybinding-signals">keybinding signal</link>
+   * which gets emitted when the user activates the entry.
+   * 
+   * Applications should not connect to it, but may emit it with
+   * g_signal_emit_by_name() if they need to control activation 
+   * programmatically.
+   *
+   * The default bindings for this signal are all forms of the Enter key.
+   */
   signals[ACTIVATE] =
     g_signal_new (I_("activate"),
                  G_OBJECT_CLASS_TYPE (gobject_class),
@@ -740,6 +1409,33 @@ gtk_entry_class_init (GtkEntryClass *class)
                  G_TYPE_NONE, 0);
   widget_class->activate_signal = signals[ACTIVATE];
 
+  /**
+   * GtkEntry::move-cursor:
+   * @entry: the object which received the signal
+   * @step: the granularity of the move, as a #GtkMovementStep
+   * @count: the number of @step units to move
+   * @extend_selection: %TRUE if the move should extend the selection
+   *
+   * The ::move-cursor signal is a
+   * <link linkend="keybinding-signals">keybinding signal</link>
+   * which gets emitted when the user initiates a cursor movement.
+   * If the cursor is not visible in @entry, this signal causes
+   * the viewport to be moved instead.
+   *
+   * Applications should not connect to it, but may emit it with
+   * g_signal_emit_by_name() if they need to control the cursor
+   * programmatically.
+   *
+   * The default bindings for this signal come in two variants,
+   * the variant with the Shift modifier extends the selection,
+   * the variant without the Shift modifer does not.
+   * There are too many key combinations to list them all here.
+   * <itemizedlist>
+   * <listitem>Arrow keys move by individual characters/lines</listitem>
+   * <listitem>Ctrl-arrow key combinations move by words/paragraphs</listitem>
+   * <listitem>Home/End keys move to the ends of the buffer</listitem>
+   * </itemizedlist>
+   */
   signals[MOVE_CURSOR] = 
     g_signal_new (I_("move-cursor"),
                  G_OBJECT_CLASS_TYPE (gobject_class),
@@ -752,6 +1448,18 @@ gtk_entry_class_init (GtkEntryClass *class)
                  G_TYPE_INT,
                  G_TYPE_BOOLEAN);
 
+  /**
+   * GtkEntry::insert-at-cursor:
+   * @entry: the object which received the signal
+   * @string: the string to insert
+   *
+   * The ::insert-at-cursor signal is a
+   * <link linkend="keybinding-signals">keybinding signal</link>
+   * which gets emitted when the user initiates the insertion of a
+   * fixed string at the cursor.
+   *
+   * This signal has no default bindings.
+   */
   signals[INSERT_AT_CURSOR] = 
     g_signal_new (I_("insert-at-cursor"),
                  G_OBJECT_CLASS_TYPE (gobject_class),
@@ -762,8 +1470,26 @@ gtk_entry_class_init (GtkEntryClass *class)
                  G_TYPE_NONE, 1,
                  G_TYPE_STRING);
 
-  signals[DELETE_FROM_CURSOR] = 
-    g_signal_new (I_("delete-from-cursor"),
+  /**
+   * GtkEntry::delete-from-cursor:
+   * @entry: the object which received the signal
+   * @type: the granularity of the deletion, as a #GtkDeleteType
+   * @count: the number of @type units to delete
+   *
+   * The ::delete-from-cursor signal is a
+   * <link linkend="keybinding-signals">keybinding signal</link>
+   * which gets emitted when the user initiates a text deletion.
+   *
+   * If the @type is %GTK_DELETE_CHARS, GTK+ deletes the selection
+   * if there is one, otherwise it deletes the requested number
+   * of characters.
+   *
+   * The default bindings for this signal are
+   * Delete for deleting a character and Ctrl-Delete for
+   * deleting a word.
+   */
+  signals[DELETE_FROM_CURSOR] = 
+    g_signal_new (I_("delete-from-cursor"),
                  G_OBJECT_CLASS_TYPE (gobject_class),
                  G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
                  G_STRUCT_OFFSET (GtkEntryClass, delete_from_cursor),
@@ -773,6 +1499,17 @@ gtk_entry_class_init (GtkEntryClass *class)
                  GTK_TYPE_DELETE_TYPE,
                  G_TYPE_INT);
 
+  /**
+   * GtkEntry::backspace:
+   * @entry: the object which received the signal
+   *
+   * The ::backspace signal is a
+   * <link linkend="keybinding-signals">keybinding signal</link>
+   * which gets emitted when the user asks for it.
+   *
+   * The default bindings for this signal are
+   * Backspace and Shift-Backspace.
+   */
   signals[BACKSPACE] =
     g_signal_new (I_("backspace"),
                  G_OBJECT_CLASS_TYPE (gobject_class),
@@ -782,6 +1519,17 @@ gtk_entry_class_init (GtkEntryClass *class)
                  _gtk_marshal_VOID__VOID,
                  G_TYPE_NONE, 0);
 
+  /**
+   * GtkEntry::cut-clipboard:
+   * @entry: the object which received the signal
+   *
+   * The ::cut-clipboard signal is a
+   * <link linkend="keybinding-signals">keybinding signal</link>
+   * which gets emitted to cut the selection to the clipboard.
+   *
+   * The default bindings for this signal are
+   * Ctrl-x and Shift-Delete.
+   */
   signals[CUT_CLIPBOARD] =
     g_signal_new (I_("cut-clipboard"),
                  G_OBJECT_CLASS_TYPE (gobject_class),
@@ -791,6 +1539,17 @@ gtk_entry_class_init (GtkEntryClass *class)
                  _gtk_marshal_VOID__VOID,
                  G_TYPE_NONE, 0);
 
+  /**
+   * GtkEntry::copy-clipboard:
+   * @entry: the object which received the signal
+   *
+   * The ::copy-clipboard signal is a
+   * <link linkend="keybinding-signals">keybinding signal</link>
+   * which gets emitted to copy the selection to the clipboard.
+   *
+   * The default bindings for this signal are
+   * Ctrl-c and Ctrl-Insert.
+   */
   signals[COPY_CLIPBOARD] =
     g_signal_new (I_("copy-clipboard"),
                  G_OBJECT_CLASS_TYPE (gobject_class),
@@ -800,6 +1559,18 @@ gtk_entry_class_init (GtkEntryClass *class)
                  _gtk_marshal_VOID__VOID,
                  G_TYPE_NONE, 0);
 
+  /**
+   * GtkEntry::paste-clipboard:
+   * @entry: the object which received the signal
+   *
+   * The ::paste-clipboard signal is a
+   * <link linkend="keybinding-signals">keybinding signal</link>
+   * which gets emitted to paste the contents of the clipboard
+   * into the text view.
+   *
+   * The default bindings for this signal are
+   * Ctrl-v and Shift-Insert.
+   */
   signals[PASTE_CLIPBOARD] =
     g_signal_new (I_("paste-clipboard"),
                  G_OBJECT_CLASS_TYPE (gobject_class),
@@ -809,6 +1580,16 @@ gtk_entry_class_init (GtkEntryClass *class)
                  _gtk_marshal_VOID__VOID,
                  G_TYPE_NONE, 0);
 
+  /**
+   * GtkEntry::toggle-overwrite:
+   * @entry: the object which received the signal
+   *
+   * The ::toggle-overwrite signal is a
+   * <link linkend="keybinding-signals">keybinding signal</link>
+   * which gets emitted to toggle the overwrite mode of the entry.
+   *
+   * The default bindings for this signal is Insert.
+   */
   signals[TOGGLE_OVERWRITE] =
     g_signal_new (I_("toggle-overwrite"),
                  G_OBJECT_CLASS_TYPE (gobject_class),
@@ -818,6 +1599,72 @@ gtk_entry_class_init (GtkEntryClass *class)
                  _gtk_marshal_VOID__VOID,
                  G_TYPE_NONE, 0);
 
+  /**
+   * GtkEntry::icon-press:
+   * @entry: The entry on which the signal is emitted
+   * @icon_pos: The position of the clicked icon
+   * @event: the button press event
+   *
+   * The ::icon-press signal is emitted when an activatable icon
+   * is clicked.
+   *
+   * Since: 2.16
+   */
+  signals[ICON_PRESS] =
+    g_signal_new (I_("icon-press"),
+                  G_TYPE_FROM_CLASS (gobject_class),
+                  G_SIGNAL_RUN_LAST,
+                  0,
+                  NULL, NULL,
+                  _gtk_marshal_VOID__ENUM_BOXED,
+                  G_TYPE_NONE, 2,
+                  GTK_TYPE_ENTRY_ICON_POSITION,
+                  GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
+  
+  /**
+   * GtkEntry::icon-release:
+   * @entry: The entry on which the signal is emitted
+   * @icon_pos: The position of the clicked icon
+   * @event: the button release event
+   *
+   * The ::icon-release signal is emitted on the button release from a
+   * mouse click over an activatable icon.
+   *
+   * Since: 2.16
+   */
+  signals[ICON_RELEASE] =
+    g_signal_new (I_("icon-release"),
+                  G_TYPE_FROM_CLASS (gobject_class),
+                  G_SIGNAL_RUN_LAST,
+                  0,
+                  NULL, NULL,
+                  _gtk_marshal_VOID__ENUM_BOXED,
+                  G_TYPE_NONE, 2,
+                  GTK_TYPE_ENTRY_ICON_POSITION,
+                  GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
+
+  /**
+   * GtkEntry::preedit-changed:
+   * @entry: the object which received the signal
+   * @preedit: the current preedit string
+   *
+   * If an input method is used, the typed text will not immediately
+   * be committed to the buffer. So if you are interested in the text,
+   * connect to this signal.
+   *
+   * Since: 2.20
+   */
+  signals[PREEDIT_CHANGED] =
+    g_signal_new_class_handler (I_("preedit-changed"),
+                                G_OBJECT_CLASS_TYPE (gobject_class),
+                                G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+                                NULL,
+                                NULL, NULL,
+                                _gtk_marshal_VOID__STRING,
+                                G_TYPE_NONE, 1,
+                                G_TYPE_STRING);
+
+
   /*
    * Key bindings
    */
@@ -825,85 +1672,85 @@ gtk_entry_class_init (GtkEntryClass *class)
   binding_set = gtk_binding_set_by_class (class);
 
   /* Moving the insertion point */
-  add_move_binding (binding_set, GDK_Right, 0,
+  add_move_binding (binding_set, GDK_KEY_Right, 0,
                    GTK_MOVEMENT_VISUAL_POSITIONS, 1);
   
-  add_move_binding (binding_set, GDK_Left, 0,
+  add_move_binding (binding_set, GDK_KEY_Left, 0,
                    GTK_MOVEMENT_VISUAL_POSITIONS, -1);
 
-  add_move_binding (binding_set, GDK_KP_Right, 0,
+  add_move_binding (binding_set, GDK_KEY_KP_Right, 0,
                    GTK_MOVEMENT_VISUAL_POSITIONS, 1);
   
-  add_move_binding (binding_set, GDK_KP_Left, 0,
+  add_move_binding (binding_set, GDK_KEY_KP_Left, 0,
                    GTK_MOVEMENT_VISUAL_POSITIONS, -1);
   
-  add_move_binding (binding_set, GDK_Right, GDK_CONTROL_MASK,
+  add_move_binding (binding_set, GDK_KEY_Right, GDK_CONTROL_MASK,
                    GTK_MOVEMENT_WORDS, 1);
 
-  add_move_binding (binding_set, GDK_Left, GDK_CONTROL_MASK,
+  add_move_binding (binding_set, GDK_KEY_Left, GDK_CONTROL_MASK,
                    GTK_MOVEMENT_WORDS, -1);
 
-  add_move_binding (binding_set, GDK_KP_Right, GDK_CONTROL_MASK,
+  add_move_binding (binding_set, GDK_KEY_KP_Right, GDK_CONTROL_MASK,
                    GTK_MOVEMENT_WORDS, 1);
 
-  add_move_binding (binding_set, GDK_KP_Left, GDK_CONTROL_MASK,
+  add_move_binding (binding_set, GDK_KEY_KP_Left, GDK_CONTROL_MASK,
                    GTK_MOVEMENT_WORDS, -1);
   
-  add_move_binding (binding_set, GDK_Home, 0,
+  add_move_binding (binding_set, GDK_KEY_Home, 0,
                    GTK_MOVEMENT_DISPLAY_LINE_ENDS, -1);
 
-  add_move_binding (binding_set, GDK_End, 0,
+  add_move_binding (binding_set, GDK_KEY_End, 0,
                    GTK_MOVEMENT_DISPLAY_LINE_ENDS, 1);
 
-  add_move_binding (binding_set, GDK_KP_Home, 0,
+  add_move_binding (binding_set, GDK_KEY_KP_Home, 0,
                    GTK_MOVEMENT_DISPLAY_LINE_ENDS, -1);
 
-  add_move_binding (binding_set, GDK_KP_End, 0,
+  add_move_binding (binding_set, GDK_KEY_KP_End, 0,
                    GTK_MOVEMENT_DISPLAY_LINE_ENDS, 1);
   
-  add_move_binding (binding_set, GDK_Home, GDK_CONTROL_MASK,
+  add_move_binding (binding_set, GDK_KEY_Home, GDK_CONTROL_MASK,
                    GTK_MOVEMENT_BUFFER_ENDS, -1);
 
-  add_move_binding (binding_set, GDK_End, GDK_CONTROL_MASK,
+  add_move_binding (binding_set, GDK_KEY_End, GDK_CONTROL_MASK,
                    GTK_MOVEMENT_BUFFER_ENDS, 1);
 
-  add_move_binding (binding_set, GDK_KP_Home, GDK_CONTROL_MASK,
+  add_move_binding (binding_set, GDK_KEY_KP_Home, GDK_CONTROL_MASK,
                    GTK_MOVEMENT_BUFFER_ENDS, -1);
 
-  add_move_binding (binding_set, GDK_KP_End, GDK_CONTROL_MASK,
+  add_move_binding (binding_set, GDK_KEY_KP_End, GDK_CONTROL_MASK,
                    GTK_MOVEMENT_BUFFER_ENDS, 1);
 
   /* Select all
    */
-  gtk_binding_entry_add_signal (binding_set, GDK_a, GDK_CONTROL_MASK,
+  gtk_binding_entry_add_signal (binding_set, GDK_KEY_a, GDK_CONTROL_MASK,
                                 "move-cursor", 3,
                                 GTK_TYPE_MOVEMENT_STEP, GTK_MOVEMENT_BUFFER_ENDS,
                                 G_TYPE_INT, -1,
                                G_TYPE_BOOLEAN, FALSE);
-  gtk_binding_entry_add_signal (binding_set, GDK_a, GDK_CONTROL_MASK,
+  gtk_binding_entry_add_signal (binding_set, GDK_KEY_a, GDK_CONTROL_MASK,
                                 "move-cursor", 3,
                                 GTK_TYPE_MOVEMENT_STEP, GTK_MOVEMENT_BUFFER_ENDS,
                                 G_TYPE_INT, 1,
                                G_TYPE_BOOLEAN, TRUE);  
 
-  gtk_binding_entry_add_signal (binding_set, GDK_slash, GDK_CONTROL_MASK,
+  gtk_binding_entry_add_signal (binding_set, GDK_KEY_slash, GDK_CONTROL_MASK,
                                 "move-cursor", 3,
                                 GTK_TYPE_MOVEMENT_STEP, GTK_MOVEMENT_BUFFER_ENDS,
                                 G_TYPE_INT, -1,
                                G_TYPE_BOOLEAN, FALSE);
-  gtk_binding_entry_add_signal (binding_set, GDK_slash, GDK_CONTROL_MASK,
+  gtk_binding_entry_add_signal (binding_set, GDK_KEY_slash, GDK_CONTROL_MASK,
                                 "move-cursor", 3,
                                 GTK_TYPE_MOVEMENT_STEP, GTK_MOVEMENT_BUFFER_ENDS,
                                 G_TYPE_INT, 1,
                                G_TYPE_BOOLEAN, TRUE);  
   /* Unselect all 
    */
-  gtk_binding_entry_add_signal (binding_set, GDK_backslash, GDK_CONTROL_MASK,
+  gtk_binding_entry_add_signal (binding_set, GDK_KEY_backslash, GDK_CONTROL_MASK,
                                 "move-cursor", 3,
                                 GTK_TYPE_MOVEMENT_STEP, GTK_MOVEMENT_VISUAL_POSITIONS,
                                 G_TYPE_INT, 0,
                                G_TYPE_BOOLEAN, FALSE);
-  gtk_binding_entry_add_signal (binding_set, GDK_a, GDK_SHIFT_MASK | GDK_CONTROL_MASK,
+  gtk_binding_entry_add_signal (binding_set, GDK_KEY_a, GDK_SHIFT_MASK | GDK_CONTROL_MASK,
                                 "move-cursor", 3,
                                 GTK_TYPE_MOVEMENT_STEP, GTK_MOVEMENT_VISUAL_POSITIONS,
                                 G_TYPE_INT, 0,
@@ -911,66 +1758,66 @@ gtk_entry_class_init (GtkEntryClass *class)
 
   /* Activate
    */
-  gtk_binding_entry_add_signal (binding_set, GDK_Return, 0,
+  gtk_binding_entry_add_signal (binding_set, GDK_KEY_Return, 0,
                                "activate", 0);
-  gtk_binding_entry_add_signal (binding_set, GDK_ISO_Enter, 0,
+  gtk_binding_entry_add_signal (binding_set, GDK_KEY_ISO_Enter, 0,
                                "activate", 0);
-  gtk_binding_entry_add_signal (binding_set, GDK_KP_Enter, 0,
+  gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Enter, 0,
                                "activate", 0);
   
   /* Deleting text */
-  gtk_binding_entry_add_signal (binding_set, GDK_Delete, 0,
+  gtk_binding_entry_add_signal (binding_set, GDK_KEY_Delete, 0,
                                "delete-from-cursor", 2,
                                G_TYPE_ENUM, GTK_DELETE_CHARS,
                                G_TYPE_INT, 1);
 
-  gtk_binding_entry_add_signal (binding_set, GDK_KP_Delete, 0,
+  gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Delete, 0,
                                "delete-from-cursor", 2,
                                G_TYPE_ENUM, GTK_DELETE_CHARS,
                                G_TYPE_INT, 1);
   
-  gtk_binding_entry_add_signal (binding_set, GDK_BackSpace, 0,
+  gtk_binding_entry_add_signal (binding_set, GDK_KEY_BackSpace, 0,
                                "backspace", 0);
 
   /* Make this do the same as Backspace, to help with mis-typing */
-  gtk_binding_entry_add_signal (binding_set, GDK_BackSpace, GDK_SHIFT_MASK,
+  gtk_binding_entry_add_signal (binding_set, GDK_KEY_BackSpace, GDK_SHIFT_MASK,
                                "backspace", 0);
 
-  gtk_binding_entry_add_signal (binding_set, GDK_Delete, GDK_CONTROL_MASK,
+  gtk_binding_entry_add_signal (binding_set, GDK_KEY_Delete, GDK_CONTROL_MASK,
                                "delete-from-cursor", 2,
                                G_TYPE_ENUM, GTK_DELETE_WORD_ENDS,
                                G_TYPE_INT, 1);
 
-  gtk_binding_entry_add_signal (binding_set, GDK_KP_Delete, GDK_CONTROL_MASK,
+  gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Delete, GDK_CONTROL_MASK,
                                "delete-from-cursor", 2,
                                G_TYPE_ENUM, GTK_DELETE_WORD_ENDS,
                                G_TYPE_INT, 1);
   
-  gtk_binding_entry_add_signal (binding_set, GDK_BackSpace, GDK_CONTROL_MASK,
+  gtk_binding_entry_add_signal (binding_set, GDK_KEY_BackSpace, GDK_CONTROL_MASK,
                                "delete-from-cursor", 2,
                                G_TYPE_ENUM, GTK_DELETE_WORD_ENDS,
                                G_TYPE_INT, -1);
 
   /* Cut/copy/paste */
 
-  gtk_binding_entry_add_signal (binding_set, GDK_x, GDK_CONTROL_MASK,
+  gtk_binding_entry_add_signal (binding_set, GDK_KEY_x, GDK_CONTROL_MASK,
                                "cut-clipboard", 0);
-  gtk_binding_entry_add_signal (binding_set, GDK_c, GDK_CONTROL_MASK,
+  gtk_binding_entry_add_signal (binding_set, GDK_KEY_c, GDK_CONTROL_MASK,
                                "copy-clipboard", 0);
-  gtk_binding_entry_add_signal (binding_set, GDK_v, GDK_CONTROL_MASK,
+  gtk_binding_entry_add_signal (binding_set, GDK_KEY_v, GDK_CONTROL_MASK,
                                "paste-clipboard", 0);
 
-  gtk_binding_entry_add_signal (binding_set, GDK_Delete, GDK_SHIFT_MASK,
+  gtk_binding_entry_add_signal (binding_set, GDK_KEY_Delete, GDK_SHIFT_MASK,
                                "cut-clipboard", 0);
-  gtk_binding_entry_add_signal (binding_set, GDK_Insert, GDK_CONTROL_MASK,
+  gtk_binding_entry_add_signal (binding_set, GDK_KEY_Insert, GDK_CONTROL_MASK,
                                "copy-clipboard", 0);
-  gtk_binding_entry_add_signal (binding_set, GDK_Insert, GDK_SHIFT_MASK,
+  gtk_binding_entry_add_signal (binding_set, GDK_KEY_Insert, GDK_SHIFT_MASK,
                                "paste-clipboard", 0);
 
   /* Overwrite */
-  gtk_binding_entry_add_signal (binding_set, GDK_Insert, 0,
+  gtk_binding_entry_add_signal (binding_set, GDK_KEY_Insert, 0,
                                "toggle-overwrite", 0);
-  gtk_binding_entry_add_signal (binding_set, GDK_KP_Insert, 0,
+  gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Insert, 0,
                                "toggle-overwrite", 0);
 
   /**
@@ -985,34 +1832,13 @@ gtk_entry_class_init (GtkEntryClass *class)
                                                                P_("Inner Border"),
                                                                P_("Border between text and frame."),
                                                                GTK_TYPE_BORDER,
-                                                               GTK_PARAM_READABLE));
-
-   gtk_settings_install_property (g_param_spec_boolean ("gtk-entry-select-on-focus",
-                                                      P_("Select on focus"),
-                                                      P_("Whether to select the contents of an entry when it is focused"),
-                                                      TRUE,
-                                                      GTK_PARAM_READWRITE));
-
-  /**
-   * GtkSettings:gtk-entry-password-hint-timeout:
-   *
-   * How long to show the last input character in hidden
-   * entries. This value is in milliseconds. 0 disables showing the
-   * last char. 600 is a good value for enabling it.
-   *
-   * Since: 2.10
-   */
-  gtk_settings_install_property (g_param_spec_uint ("gtk-entry-password-hint-timeout",
-                                                    P_("Password Hint Timeout"),
-                                                    P_("How long to show the last input character in hidden entries"),
-                                                    0, G_MAXUINT, 0,
-                                                    GTK_PARAM_READWRITE));
+                                                               GTK_PARAM_READABLE)); 
 
   g_type_class_add_private (gobject_class, sizeof (GtkEntryPrivate));
 }
 
 static void
-gtk_entry_editable_init (GtkEditableClass *iface)
+gtk_entry_editable_init (GtkEditableInterface *iface)
 {
   iface->do_insert_text = gtk_entry_insert_text;
   iface->do_delete_text = gtk_entry_delete_text;
@@ -1037,33 +1863,39 @@ gtk_entry_set_property (GObject         *object,
                         const GValue    *value,
                         GParamSpec      *pspec)
 {
-  GtkEntryPrivate *priv = GTK_ENTRY_GET_PRIVATE (object);
   GtkEntry *entry = GTK_ENTRY (object);
+  GtkEntryPrivate *priv = entry->priv;
 
   switch (prop_id)
     {
+    case PROP_BUFFER:
+      gtk_entry_set_buffer (entry, g_value_get_object (value));
+      break;
+
     case PROP_EDITABLE:
       {
         gboolean new_value = g_value_get_boolean (value);
 
-       if (new_value != entry->editable)
+        if (new_value != priv->editable)
          {
+            GtkWidget *widget = GTK_WIDGET (entry);
+
            if (!new_value)
              {
                _gtk_entry_reset_im_context (entry);
-               if (GTK_WIDGET_HAS_FOCUS (entry))
-                 gtk_im_context_focus_out (entry->im_context);
+               if (gtk_widget_has_focus (widget))
+                 gtk_im_context_focus_out (priv->im_context);
 
-               entry->preedit_length = 0;
-               entry->preedit_cursor = 0;
+               priv->preedit_length = 0;
+               priv->preedit_cursor = 0;
              }
 
-           entry->editable = new_value;
+           priv->editable = new_value;
+
+           if (new_value && gtk_widget_has_focus (widget))
+             gtk_im_context_focus_in (priv->im_context);
 
-           if (new_value && GTK_WIDGET_HAS_FOCUS (entry))
-             gtk_im_context_focus_in (entry->im_context);
-           
-           gtk_entry_queue_draw (entry);
+           gtk_widget_queue_draw (widget);
          }
       }
       break;
@@ -1105,7 +1937,7 @@ gtk_entry_set_property (GObject         *object,
       break;
 
     case PROP_TRUNCATE_MULTILINE:
-      entry->truncate_multiline = g_value_get_boolean (value);
+      priv->truncate_multiline = g_value_get_boolean (value);
       break;
 
     case PROP_SHADOW_TYPE:
@@ -1127,6 +1959,121 @@ gtk_entry_set_property (GObject         *object,
       priv->caps_lock_warning = g_value_get_boolean (value);
       break;
 
+    case PROP_PROGRESS_FRACTION:
+      gtk_entry_set_progress_fraction (entry, g_value_get_double (value));
+      break;
+
+    case PROP_PROGRESS_PULSE_STEP:
+      gtk_entry_set_progress_pulse_step (entry, g_value_get_double (value));
+      break;
+
+    case PROP_PIXBUF_PRIMARY:
+      gtk_entry_set_icon_from_pixbuf (entry,
+                                      GTK_ENTRY_ICON_PRIMARY,
+                                      g_value_get_object (value));
+      break;
+
+    case PROP_PIXBUF_SECONDARY:
+      gtk_entry_set_icon_from_pixbuf (entry,
+                                      GTK_ENTRY_ICON_SECONDARY,
+                                      g_value_get_object (value));
+      break;
+
+    case PROP_STOCK_PRIMARY:
+      gtk_entry_set_icon_from_stock (entry,
+                                     GTK_ENTRY_ICON_PRIMARY,
+                                     g_value_get_string (value));
+      break;
+
+    case PROP_STOCK_SECONDARY:
+      gtk_entry_set_icon_from_stock (entry,
+                                     GTK_ENTRY_ICON_SECONDARY,
+                                     g_value_get_string (value));
+      break;
+
+    case PROP_ICON_NAME_PRIMARY:
+      gtk_entry_set_icon_from_icon_name (entry,
+                                         GTK_ENTRY_ICON_PRIMARY,
+                                         g_value_get_string (value));
+      break;
+
+    case PROP_ICON_NAME_SECONDARY:
+      gtk_entry_set_icon_from_icon_name (entry,
+                                         GTK_ENTRY_ICON_SECONDARY,
+                                         g_value_get_string (value));
+      break;
+
+    case PROP_GICON_PRIMARY:
+      gtk_entry_set_icon_from_gicon (entry,
+                                     GTK_ENTRY_ICON_PRIMARY,
+                                     g_value_get_object (value));
+      break;
+
+    case PROP_GICON_SECONDARY:
+      gtk_entry_set_icon_from_gicon (entry,
+                                     GTK_ENTRY_ICON_SECONDARY,
+                                     g_value_get_object (value));
+      break;
+
+    case PROP_ACTIVATABLE_PRIMARY:
+      gtk_entry_set_icon_activatable (entry,
+                                      GTK_ENTRY_ICON_PRIMARY,
+                                      g_value_get_boolean (value));
+      break;
+
+    case PROP_ACTIVATABLE_SECONDARY:
+      gtk_entry_set_icon_activatable (entry,
+                                      GTK_ENTRY_ICON_SECONDARY,
+                                      g_value_get_boolean (value));
+      break;
+
+    case PROP_SENSITIVE_PRIMARY:
+      gtk_entry_set_icon_sensitive (entry,
+                                    GTK_ENTRY_ICON_PRIMARY,
+                                    g_value_get_boolean (value));
+      break;
+
+    case PROP_SENSITIVE_SECONDARY:
+      gtk_entry_set_icon_sensitive (entry,
+                                    GTK_ENTRY_ICON_SECONDARY,
+                                    g_value_get_boolean (value));
+      break;
+
+    case PROP_TOOLTIP_TEXT_PRIMARY:
+      gtk_entry_set_icon_tooltip_text (entry,
+                                       GTK_ENTRY_ICON_PRIMARY,
+                                       g_value_get_string (value));
+      break;
+
+    case PROP_TOOLTIP_TEXT_SECONDARY:
+      gtk_entry_set_icon_tooltip_text (entry,
+                                       GTK_ENTRY_ICON_SECONDARY,
+                                       g_value_get_string (value));
+      break;
+
+    case PROP_TOOLTIP_MARKUP_PRIMARY:
+      gtk_entry_set_icon_tooltip_markup (entry,
+                                         GTK_ENTRY_ICON_PRIMARY,
+                                         g_value_get_string (value));
+      break;
+
+    case PROP_TOOLTIP_MARKUP_SECONDARY:
+      gtk_entry_set_icon_tooltip_markup (entry,
+                                         GTK_ENTRY_ICON_SECONDARY,
+                                         g_value_get_string (value));
+      break;
+
+    case PROP_IM_MODULE:
+      g_free (priv->im_module);
+      priv->im_module = g_value_dup_string (value);
+      if (GTK_IS_IM_MULTICONTEXT (priv->im_context))
+        gtk_im_multicontext_set_context_id (GTK_IM_MULTICONTEXT (priv->im_context), priv->im_module);
+      break;
+
+    case PROP_EDITING_CANCELED:
+      priv->editing_canceled = g_value_get_boolean (value);
+      break;
+
     case PROP_SCROLL_OFFSET:
     case PROP_CURSOR_POSITION:
     default:
@@ -1141,68 +2088,208 @@ gtk_entry_get_property (GObject         *object,
                         GValue          *value,
                         GParamSpec      *pspec)
 {
-  GtkEntryPrivate *priv = GTK_ENTRY_GET_PRIVATE (object);
   GtkEntry *entry = GTK_ENTRY (object);
+  GtkEntryPrivate *priv = entry->priv;
 
   switch (prop_id)
     {
+    case PROP_BUFFER:
+      g_value_set_object (value, gtk_entry_get_buffer (entry));
+      break;
+
     case PROP_CURSOR_POSITION:
-      g_value_set_int (value, entry->current_pos);
+      g_value_set_int (value, priv->current_pos);
       break;
+
     case PROP_SELECTION_BOUND:
-      g_value_set_int (value, entry->selection_bound);
+      g_value_set_int (value, priv->selection_bound);
       break;
+
     case PROP_EDITABLE:
-      g_value_set_boolean (value, entry->editable);
+      g_value_set_boolean (value, priv->editable);
       break;
+
     case PROP_MAX_LENGTH:
-      g_value_set_int (value, entry->text_max_length); 
+      g_value_set_int (value, gtk_entry_buffer_get_max_length (get_buffer (entry)));
       break;
+
     case PROP_VISIBILITY:
-      g_value_set_boolean (value, entry->visible);
+      g_value_set_boolean (value, priv->visible);
       break;
+
     case PROP_HAS_FRAME:
-      g_value_set_boolean (value, entry->has_frame);
+      g_value_set_boolean (value, priv->has_frame);
       break;
+
     case PROP_INNER_BORDER:
       g_value_set_boxed (value, gtk_entry_get_inner_border (entry));
       break;
+
     case PROP_INVISIBLE_CHAR:
-      g_value_set_uint (value, entry->invisible_char);
+      g_value_set_uint (value, priv->invisible_char);
       break;
+
     case PROP_ACTIVATES_DEFAULT:
-      g_value_set_boolean (value, entry->activates_default);
+      g_value_set_boolean (value, priv->activates_default);
       break;
+
     case PROP_WIDTH_CHARS:
-      g_value_set_int (value, entry->width_chars);
+      g_value_set_int (value, priv->width_chars);
       break;
+
     case PROP_SCROLL_OFFSET:
-      g_value_set_int (value, entry->scroll_offset);
+      g_value_set_int (value, priv->scroll_offset);
       break;
+
     case PROP_TEXT:
       g_value_set_string (value, gtk_entry_get_text (entry));
       break;
+
     case PROP_XALIGN:
       g_value_set_float (value, gtk_entry_get_alignment (entry));
       break;
+
     case PROP_TRUNCATE_MULTILINE:
-      g_value_set_boolean (value, entry->truncate_multiline);
+      g_value_set_boolean (value, priv->truncate_multiline);
       break;
+
     case PROP_SHADOW_TYPE:
       g_value_set_enum (value, priv->shadow_type);
       break;
+
     case PROP_OVERWRITE_MODE:
-      g_value_set_boolean (value, entry->overwrite_mode);
+      g_value_set_boolean (value, priv->overwrite_mode);
       break;
+
     case PROP_TEXT_LENGTH:
-      g_value_set_uint (value, entry->text_length);
+      g_value_set_uint (value, gtk_entry_buffer_get_length (get_buffer (entry)));
       break;
+
     case PROP_INVISIBLE_CHAR_SET:
       g_value_set_boolean (value, priv->invisible_char_set);
       break;
+
+    case PROP_IM_MODULE:
+      g_value_set_string (value, priv->im_module);
+      break;
+
     case PROP_CAPS_LOCK_WARNING:
       g_value_set_boolean (value, priv->caps_lock_warning);
       break;
+
+    case PROP_PROGRESS_FRACTION:
+      g_value_set_double (value, priv->progress_fraction);
+      break;
+
+    case PROP_PROGRESS_PULSE_STEP:
+      g_value_set_double (value, priv->progress_pulse_fraction);
+      break;
+
+    case PROP_PIXBUF_PRIMARY:
+      g_value_set_object (value,
+                          gtk_entry_get_icon_pixbuf (entry,
+                                                     GTK_ENTRY_ICON_PRIMARY));
+      break;
+
+    case PROP_PIXBUF_SECONDARY:
+      g_value_set_object (value,
+                          gtk_entry_get_icon_pixbuf (entry,
+                                                     GTK_ENTRY_ICON_SECONDARY));
+      break;
+
+    case PROP_STOCK_PRIMARY:
+      g_value_set_string (value,
+                          gtk_entry_get_icon_stock (entry,
+                                                    GTK_ENTRY_ICON_PRIMARY));
+      break;
+
+    case PROP_STOCK_SECONDARY:
+      g_value_set_string (value,
+                          gtk_entry_get_icon_stock (entry,
+                                                    GTK_ENTRY_ICON_SECONDARY));
+      break;
+
+    case PROP_ICON_NAME_PRIMARY:
+      g_value_set_string (value,
+                          gtk_entry_get_icon_name (entry,
+                                                   GTK_ENTRY_ICON_PRIMARY));
+      break;
+
+    case PROP_ICON_NAME_SECONDARY:
+      g_value_set_string (value,
+                          gtk_entry_get_icon_name (entry,
+                                                   GTK_ENTRY_ICON_SECONDARY));
+      break;
+
+    case PROP_GICON_PRIMARY:
+      g_value_set_object (value,
+                          gtk_entry_get_icon_gicon (entry,
+                                                    GTK_ENTRY_ICON_PRIMARY));
+      break;
+
+    case PROP_GICON_SECONDARY:
+      g_value_set_object (value,
+                          gtk_entry_get_icon_gicon (entry,
+                                                    GTK_ENTRY_ICON_SECONDARY));
+      break;
+
+    case PROP_STORAGE_TYPE_PRIMARY:
+      g_value_set_enum (value,
+                        gtk_entry_get_icon_storage_type (entry, 
+                                                         GTK_ENTRY_ICON_PRIMARY));
+      break;
+
+    case PROP_STORAGE_TYPE_SECONDARY:
+      g_value_set_enum (value,
+                        gtk_entry_get_icon_storage_type (entry, 
+                                                         GTK_ENTRY_ICON_SECONDARY));
+      break;
+
+    case PROP_ACTIVATABLE_PRIMARY:
+      g_value_set_boolean (value,
+                           gtk_entry_get_icon_activatable (entry, GTK_ENTRY_ICON_PRIMARY));
+      break;
+
+    case PROP_ACTIVATABLE_SECONDARY:
+      g_value_set_boolean (value,
+                           gtk_entry_get_icon_activatable (entry, GTK_ENTRY_ICON_SECONDARY));
+      break;
+
+    case PROP_SENSITIVE_PRIMARY:
+      g_value_set_boolean (value,
+                           gtk_entry_get_icon_sensitive (entry, GTK_ENTRY_ICON_PRIMARY));
+      break;
+
+    case PROP_SENSITIVE_SECONDARY:
+      g_value_set_boolean (value,
+                           gtk_entry_get_icon_sensitive (entry, GTK_ENTRY_ICON_SECONDARY));
+      break;
+
+    case PROP_TOOLTIP_TEXT_PRIMARY:
+      g_value_take_string (value,
+                           gtk_entry_get_icon_tooltip_text (entry, GTK_ENTRY_ICON_PRIMARY));
+      break;
+
+    case PROP_TOOLTIP_TEXT_SECONDARY:
+      g_value_take_string (value,
+                           gtk_entry_get_icon_tooltip_text (entry, GTK_ENTRY_ICON_SECONDARY));
+      break;
+
+    case PROP_TOOLTIP_MARKUP_PRIMARY:
+      g_value_take_string (value,
+                           gtk_entry_get_icon_tooltip_markup (entry, GTK_ENTRY_ICON_PRIMARY));
+      break;
+
+    case PROP_TOOLTIP_MARKUP_SECONDARY:
+      g_value_take_string (value,
+                           gtk_entry_get_icon_tooltip_markup (entry, GTK_ENTRY_ICON_SECONDARY));
+      break;
+
+    case PROP_EDITING_CANCELED:
+      g_value_set_boolean (value,
+                           priv->editing_canceled);
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -1216,12 +2303,17 @@ find_invisible_char (GtkWidget *widget)
   PangoAttrList *attr_list;
   gint i;
   gunichar invisible_chars [] = {
+    0,
     0x25cf, /* BLACK CIRCLE */
     0x2022, /* BULLET */
     0x2731, /* HEAVY ASTERISK */
     0x273a  /* SIXTEEN POINTED ASTERISK */
   };
 
+  gtk_widget_style_get (widget,
+                        "invisible-char", &invisible_chars[0],
+                        NULL);
+
   layout = gtk_widget_create_pango_layout (widget, NULL);
 
   attr_list = pango_attr_list_new ();
@@ -1230,7 +2322,7 @@ find_invisible_char (GtkWidget *widget)
   pango_layout_set_attributes (layout, attr_list);
   pango_attr_list_unref (attr_list);
 
-  for (i = 0; i < G_N_ELEMENTS (invisible_chars); i++)
+  for (i = (invisible_chars[0] != 0 ? 0 : 1); i < G_N_ELEMENTS (invisible_chars); i++)
     {
       gchar text[7] = { 0, };
       gint len, count;
@@ -1248,32 +2340,39 @@ find_invisible_char (GtkWidget *widget)
     }
 
   g_object_unref (layout);
+
   return '*';
 }
 
 static void
 gtk_entry_init (GtkEntry *entry)
 {
-  GtkEntryPrivate *priv = GTK_ENTRY_GET_PRIVATE (entry);
-  
-  GTK_WIDGET_SET_FLAGS (entry, GTK_CAN_FOCUS);
-
-  entry->text_size = MIN_SIZE;
-  entry->text = g_malloc (entry->text_size);
-  entry->text[0] = '\0';
-
-  entry->editable = TRUE;
-  entry->visible = TRUE;
-  entry->invisible_char = find_invisible_char (GTK_WIDGET (entry));
-  entry->dnd_position = -1;
-  entry->width_chars = -1;
-  entry->is_cell_renderer = FALSE;
-  entry->editing_canceled = FALSE;
-  entry->has_frame = TRUE;
-  entry->truncate_multiline = FALSE;
+  GtkStyleContext *context;
+  GtkEntryPrivate *priv;
+
+  entry->priv = G_TYPE_INSTANCE_GET_PRIVATE (entry,
+                                             GTK_TYPE_ENTRY,
+                                             GtkEntryPrivate);
+  priv = entry->priv;
+
+  gtk_widget_set_can_focus (GTK_WIDGET (entry), TRUE);
+  gtk_widget_set_has_window (GTK_WIDGET (entry), FALSE);
+
+  priv->editable = TRUE;
+  priv->visible = TRUE;
+  priv->invisible_char = find_invisible_char (GTK_WIDGET (entry));
+  priv->dnd_position = -1;
+  priv->width_chars = -1;
+  priv->is_cell_renderer = FALSE;
+  priv->editing_canceled = FALSE;
+  priv->has_frame = TRUE;
+  priv->truncate_multiline = FALSE;
   priv->shadow_type = GTK_SHADOW_IN;
   priv->xalign = 0.0;
   priv->caps_lock_warning = TRUE;
+  priv->caps_lock_warning_shown = FALSE;
+  priv->progress_fraction = 0.0;
+  priv->progress_pulse_fraction = 0.1;
 
   gtk_drag_dest_set (GTK_WIDGET (entry),
                      GTK_DEST_DEFAULT_HIGHLIGHT,
@@ -1284,22 +2383,86 @@ gtk_entry_init (GtkEntry *entry)
   /* This object is completely private. No external entity can gain a reference
    * to it; so we create it here and destroy it in finalize().
    */
-  entry->im_context = gtk_im_multicontext_new ();
-  
-  g_signal_connect (entry->im_context, "commit",
+  priv->im_context = gtk_im_multicontext_new ();
+
+  g_signal_connect (priv->im_context, "commit",
                    G_CALLBACK (gtk_entry_commit_cb), entry);
-  g_signal_connect (entry->im_context, "preedit-changed",
+  g_signal_connect (priv->im_context, "preedit-changed",
                    G_CALLBACK (gtk_entry_preedit_changed_cb), entry);
-  g_signal_connect (entry->im_context, "retrieve-surrounding",
+  g_signal_connect (priv->im_context, "retrieve-surrounding",
                    G_CALLBACK (gtk_entry_retrieve_surrounding_cb), entry);
-  g_signal_connect (entry->im_context, "delete-surrounding",
+  g_signal_connect (priv->im_context, "delete-surrounding",
                    G_CALLBACK (gtk_entry_delete_surrounding_cb), entry);
+
+  context = gtk_widget_get_style_context (GTK_WIDGET (entry));
+  gtk_style_context_add_class (context, GTK_STYLE_CLASS_ENTRY);
+}
+
+static gint
+get_icon_width (GtkEntry             *entry,
+                GtkEntryIconPosition  icon_pos)
+{
+  GtkEntryPrivate *priv = entry->priv;
+  EntryIconInfo *icon_info = priv->icons[icon_pos];
+  GdkScreen *screen;
+  GtkSettings *settings;
+  gint menu_icon_width;
+
+  if (!icon_info || icon_info->pixbuf == NULL)
+    return 0;
+
+  screen = gtk_widget_get_screen (GTK_WIDGET (entry));
+  settings = gtk_settings_get_for_screen (screen);
+
+  gtk_icon_size_lookup_for_settings (settings, GTK_ICON_SIZE_MENU,
+                                     &menu_icon_width, NULL);
+
+  return MAX (gdk_pixbuf_get_width (icon_info->pixbuf), menu_icon_width);
+}
+
+static void
+get_icon_allocations (GtkEntry      *entry,
+                      GtkAllocation *primary,
+                      GtkAllocation *secondary)
+
+{
+  GtkEntryPrivate *priv = entry->priv;
+  gint x, y, width, height;
+
+  get_text_area_size (entry, &x, &y, &width, &height);
+
+  if (gtk_widget_has_focus (GTK_WIDGET (entry)) && !priv->interior_focus)
+    y += priv->focus_width;
+
+  primary->y = y;
+  primary->height = height;
+  primary->width = get_icon_width (entry, GTK_ENTRY_ICON_PRIMARY);
+  if (primary->width > 0)
+    primary->width += 2 * priv->icon_margin;
+
+  secondary->y = y;
+  secondary->height = height;
+  secondary->width = get_icon_width (entry, GTK_ENTRY_ICON_SECONDARY);
+  if (secondary->width > 0)
+    secondary->width += 2 * priv->icon_margin;
+
+  if (gtk_widget_get_direction (GTK_WIDGET (entry)) == GTK_TEXT_DIR_RTL)
+    {
+      primary->x = x + width - primary->width;
+      secondary->x = x;
+    }
+  else
+    {
+      primary->x = x;
+      secondary->x = x + width - secondary->width;
+    }
 }
 
+
 static void
 begin_change (GtkEntry *entry)
 {
-  GtkEntryPrivate *priv = GTK_ENTRY_GET_PRIVATE (entry);
+  GtkEntryPrivate *priv = entry->priv;
 
   priv->change_count++;
 }
@@ -1308,195 +2471,463 @@ static void
 end_change (GtkEntry *entry)
 {
   GtkEditable *editable = GTK_EDITABLE (entry);
-  GtkEntryPrivate *priv = GTK_ENTRY_GET_PRIVATE (entry);
+  GtkEntryPrivate *priv = entry->priv;
+
   g_return_if_fail (priv->change_count > 0);
 
   priv->change_count--;
 
   if (priv->change_count == 0)
     {
-       if (priv->real_changed) 
+       if (priv->real_changed)
          {
            g_signal_emit_by_name (editable, "changed");
            priv->real_changed = FALSE;
          }
-    } 
+    }
 }
 
 static void
 emit_changed (GtkEntry *entry)
 {
   GtkEditable *editable = GTK_EDITABLE (entry);
-  GtkEntryPrivate *priv = GTK_ENTRY_GET_PRIVATE (entry);
+  GtkEntryPrivate *priv = entry->priv;
 
   if (priv->change_count == 0)
     g_signal_emit_by_name (editable, "changed");
-  else 
+  else
     priv->real_changed = TRUE;
 }
 
-/*
- * Overwrite a memory that might contain sensitive information.
- */
-static void
-trash_area (gchar *area, gsize len)
-{
-  volatile gchar *varea = (volatile gchar *)area;
-  while (len-- > 0)
-    *varea++ = 0;
-}
-
 static void
-gtk_entry_destroy (GtkObject *object)
+gtk_entry_destroy (GtkWidget *widget)
 {
-  GtkEntry *entry = GTK_ENTRY (object);
+  GtkEntry *entry = GTK_ENTRY (widget);
+  GtkEntryPrivate *priv = entry->priv;
 
-  entry->n_bytes = 0;
-  entry->current_pos = entry->selection_bound = entry->text_length = 0;
+  priv->current_pos = priv->selection_bound = 0;
   _gtk_entry_reset_im_context (entry);
   gtk_entry_reset_layout (entry);
 
-  if (entry->blink_timeout)
+  if (priv->blink_timeout)
     {
-      g_source_remove (entry->blink_timeout);
-      entry->blink_timeout = 0;
+      g_source_remove (priv->blink_timeout);
+      priv->blink_timeout = 0;
     }
 
-  if (entry->recompute_idle)
+  if (priv->recompute_idle)
     {
-      g_source_remove (entry->recompute_idle);
-      entry->recompute_idle = 0;
+      g_source_remove (priv->recompute_idle);
+      priv->recompute_idle = 0;
     }
 
-  if (!entry->visible)
+  GTK_WIDGET_CLASS (gtk_entry_parent_class)->destroy (widget);
+}
+
+static void
+gtk_entry_dispose (GObject *object)
+{
+  GtkEntry *entry = GTK_ENTRY (object);
+  GtkEntryPrivate *priv = entry->priv;
+
+  gtk_entry_set_icon_from_pixbuf (entry, GTK_ENTRY_ICON_PRIMARY, NULL);
+  gtk_entry_set_icon_tooltip_markup (entry, GTK_ENTRY_ICON_PRIMARY, NULL);
+  gtk_entry_set_icon_from_pixbuf (entry, GTK_ENTRY_ICON_SECONDARY, NULL);
+  gtk_entry_set_icon_tooltip_markup (entry, GTK_ENTRY_ICON_SECONDARY, NULL);
+
+  if (priv->buffer)
     {
-      /* We want to trash the text here because the entry might be leaked.  */
-      trash_area (entry->text, strlen (entry->text));
+      buffer_disconnect_signals (entry);
+      g_object_unref (priv->buffer);
+      priv->buffer = NULL;
     }
 
-  GTK_OBJECT_CLASS (gtk_entry_parent_class)->destroy (object);
+  G_OBJECT_CLASS (gtk_entry_parent_class)->dispose (object);
 }
 
 static void
 gtk_entry_finalize (GObject *object)
 {
   GtkEntry *entry = GTK_ENTRY (object);
+  GtkEntryPrivate *priv = entry->priv;
+  EntryIconInfo *icon_info = NULL;
+  gint i;
 
-  gtk_entry_set_completion (entry, NULL);
+  for (i = 0; i < MAX_ICONS; i++)
+    {
+      if ((icon_info = priv->icons[i]) != NULL)
+        {
+          if (icon_info->target_list != NULL)
+            {
+              gtk_target_list_unref (icon_info->target_list);
+              icon_info->target_list = NULL;
+            }
 
-  if (entry->cached_layout)
-    g_object_unref (entry->cached_layout);
+          g_slice_free (EntryIconInfo, icon_info);
+          priv->icons[i] = NULL;
+        }
+    }
 
-  g_object_unref (entry->im_context);
+  gtk_entry_set_completion (entry, NULL);
 
-  if (entry->blink_timeout)
-    g_source_remove (entry->blink_timeout);
+  if (priv->cached_layout)
+    g_object_unref (priv->cached_layout);
 
-  if (entry->recompute_idle)
-    g_source_remove (entry->recompute_idle);
+  g_object_unref (priv->im_context);
 
-  entry->text_size = 0;
+  if (priv->blink_timeout)
+    g_source_remove (priv->blink_timeout);
 
-  if (entry->text)
-    {
-      if (!entry->visible)
-       trash_area (entry->text, strlen (entry->text));
-      g_free (entry->text);
-      entry->text = NULL;
-    }
+  if (priv->recompute_idle)
+    g_source_remove (priv->recompute_idle);
+
+  g_free (priv->im_module);
 
   G_OBJECT_CLASS (gtk_entry_parent_class)->finalize (object);
 }
 
-static void
-gtk_entry_realize (GtkWidget *widget)
+static DisplayMode
+gtk_entry_get_display_mode (GtkEntry *entry)
 {
-  GtkEntry *entry;
-  GdkWindowAttr attributes;
-  gint attributes_mask;
+  GtkEntryPrivate *priv = entry->priv;
 
-  GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
-  entry = GTK_ENTRY (widget);
+  if (priv->visible)
+    return DISPLAY_NORMAL;
 
-  attributes.window_type = GDK_WINDOW_CHILD;
-  
-  get_widget_window_size (entry, &attributes.x, &attributes.y, &attributes.width, &attributes.height);
+  if (priv->invisible_char == 0 && priv->invisible_char_set)
+    return DISPLAY_BLANK;
 
-  attributes.wclass = GDK_INPUT_OUTPUT;
-  attributes.visual = gtk_widget_get_visual (widget);
-  attributes.colormap = gtk_widget_get_colormap (widget);
-  attributes.event_mask = gtk_widget_get_events (widget);
-  attributes.event_mask |= (GDK_EXPOSURE_MASK |
-                           GDK_BUTTON_PRESS_MASK |
-                           GDK_BUTTON_RELEASE_MASK |
-                           GDK_BUTTON1_MOTION_MASK |
-                           GDK_BUTTON3_MOTION_MASK |
-                           GDK_POINTER_MOTION_HINT_MASK |
-                           GDK_POINTER_MOTION_MASK |
-                            GDK_ENTER_NOTIFY_MASK |
-                           GDK_LEAVE_NOTIFY_MASK);
-  attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
+  return DISPLAY_INVISIBLE;
+}
 
-  widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask);
-  gdk_window_set_user_data (widget->window, entry);
+static gchar*
+gtk_entry_get_display_text (GtkEntry *entry,
+                            gint      start_pos,
+                            gint      end_pos)
+{
+  GtkEntryPasswordHint *password_hint;
+  GtkEntryPrivate *priv;
+  gunichar invisible_char;
+  const gchar *start;
+  const gchar *end;
+  const gchar *text;
+  gchar char_str[7];
+  gint char_len;
+  GString *str;
+  guint length;
+  gint i;
 
-  get_text_area_size (entry, &attributes.x, &attributes.y, &attributes.width, &attributes.height);
-  if (GTK_WIDGET_IS_SENSITIVE (widget))
-    {
-      attributes.cursor = gdk_cursor_new_for_display (gtk_widget_get_display (widget), GDK_XTERM);
-      attributes_mask |= GDK_WA_CURSOR;
+  priv = entry->priv;
+  text = gtk_entry_buffer_get_text (get_buffer (entry));
+  length = gtk_entry_buffer_get_length (get_buffer (entry));
+
+  if (end_pos < 0)
+    end_pos = length;
+  if (start_pos > length)
+    start_pos = length;
+
+  if (end_pos <= start_pos)
+      return g_strdup ("");
+  else if (priv->visible)
+    {
+      start = g_utf8_offset_to_pointer (text, start_pos);
+      end = g_utf8_offset_to_pointer (start, end_pos - start_pos);
+      return g_strndup (start, end - start);
     }
+  else
+    {
+      str = g_string_sized_new (length * 2);
 
-  entry->text_area = gdk_window_new (widget->window, &attributes, attributes_mask);
+      /* Figure out what our invisible char is and encode it */
+      if (!priv->invisible_char)
+          invisible_char = priv->invisible_char_set ? ' ' : '*';
+      else
+          invisible_char = priv->invisible_char;
+      char_len = g_unichar_to_utf8 (invisible_char, char_str);
 
-  gdk_window_set_user_data (entry->text_area, entry);
+      /*
+       * Add hidden characters for each character in the text
+       * buffer. If there is a password hint, then keep that
+       * character visible.
+       */
 
-  if (attributes_mask & GDK_WA_CURSOR)
-    gdk_cursor_unref (attributes.cursor);
+      password_hint = g_object_get_qdata (G_OBJECT (entry), quark_password_hint);
+      for (i = start_pos; i < end_pos; ++i)
+        {
+          if (password_hint && i == password_hint->position)
+            {
+              start = g_utf8_offset_to_pointer (text, i);
+              g_string_append_len (str, start, g_utf8_next_char (start) - start);
+            }
+          else
+            {
+              g_string_append_len (str, char_str, char_len);
+            }
+        }
+
+      return g_string_free (str, FALSE);
+    }
+
+}
+
+static void
+update_cursors (GtkWidget *widget)
+{
+  GtkEntry *entry = GTK_ENTRY (widget);
+  GtkEntryPrivate *priv = entry->priv;
+  EntryIconInfo *icon_info = NULL;
+  GdkDisplay *display;
+  GdkCursor *cursor;
+  gint i;
+
+  for (i = 0; i < MAX_ICONS; i++)
+    {
+      if ((icon_info = priv->icons[i]) != NULL)
+        {
+          if (icon_info->pixbuf != NULL && icon_info->window != NULL)
+            gdk_window_show_unraised (icon_info->window);
+
+          /* The icon windows are not children of the visible entry window,
+           * thus we can't just inherit the xterm cursor. Slight complication 
+           * here is that for the entry, insensitive => arrow cursor, but for 
+           * an icon in a sensitive entry, insensitive => xterm cursor.
+           */
+          if (gtk_widget_is_sensitive (widget) &&
+              (icon_info->insensitive || 
+               (icon_info->nonactivatable && icon_info->target_list == NULL)))
+            {
+              display = gtk_widget_get_display (widget);
+              cursor = gdk_cursor_new_for_display (display, GDK_XTERM);
+              gdk_window_set_cursor (icon_info->window, cursor);
+              g_object_unref (cursor);
+            }
+          else
+            {
+              gdk_window_set_cursor (icon_info->window, NULL);
+            }
+        }
+    }
+}
+
+static void
+realize_icon_info (GtkWidget            *widget, 
+                   GtkEntryIconPosition  icon_pos)
+{
+  GtkEntry *entry = GTK_ENTRY (widget);
+  GtkEntryPrivate *priv = entry->priv;
+  EntryIconInfo *icon_info = priv->icons[icon_pos];
+  GdkWindowAttr attributes;
+  gint attributes_mask;
+
+  g_return_if_fail (icon_info != NULL);
+
+  attributes.x = 0;
+  attributes.y = 0;
+  attributes.width = 1;
+  attributes.height = 1;
+  attributes.window_type = GDK_WINDOW_CHILD;
+  attributes.wclass = GDK_INPUT_ONLY;
+  attributes.event_mask = gtk_widget_get_events (widget);
+  attributes.event_mask |= (GDK_BUTTON_PRESS_MASK |
+                                GDK_BUTTON_RELEASE_MASK |
+                                GDK_BUTTON1_MOTION_MASK |
+                                GDK_BUTTON3_MOTION_MASK |
+                                GDK_POINTER_MOTION_HINT_MASK |
+                                GDK_POINTER_MOTION_MASK |
+                                GDK_ENTER_NOTIFY_MASK |
+                            GDK_LEAVE_NOTIFY_MASK);
+  attributes_mask = GDK_WA_X | GDK_WA_Y;
+
+  icon_info->window = gdk_window_new (gtk_widget_get_window (widget),
+                                      &attributes,
+                                      attributes_mask);
+  gdk_window_set_user_data (icon_info->window, widget);
+
+  gtk_widget_queue_resize (widget);
+}
+
+static EntryIconInfo*
+construct_icon_info (GtkWidget            *widget, 
+                     GtkEntryIconPosition  icon_pos)
+{
+  GtkEntry *entry = GTK_ENTRY (widget);
+  GtkEntryPrivate *priv = entry->priv;
+  EntryIconInfo *icon_info;
+
+  g_return_val_if_fail (priv->icons[icon_pos] == NULL, NULL);
+
+  icon_info = g_slice_new0 (EntryIconInfo);
+  priv->icons[icon_pos] = icon_info;
+
+  if (gtk_widget_get_realized (widget))
+    realize_icon_info (widget, icon_pos);
+
+  return icon_info;
+}
+
+static void
+gtk_entry_map (GtkWidget *widget)
+{
+  GtkEntry *entry = GTK_ENTRY (widget);
+  GtkEntryPrivate *priv = entry->priv;
+  EntryIconInfo *icon_info = NULL;
+  gint i;
+
+  GTK_WIDGET_CLASS (gtk_entry_parent_class)->map (widget);
+
+  gdk_window_show (priv->text_area);
+
+  for (i = 0; i < MAX_ICONS; i++)
+    {
+      if ((icon_info = priv->icons[i]) != NULL)
+        {
+          if (icon_info->pixbuf != NULL && icon_info->window != NULL)
+            gdk_window_show (icon_info->window);
+        }
+    }
+
+  update_cursors (widget);
+}
+
+static void
+gtk_entry_unmap (GtkWidget *widget)
+{
+  GtkEntry *entry = GTK_ENTRY (widget);
+  GtkEntryPrivate *priv = entry->priv;
+  EntryIconInfo *icon_info = NULL;
+  gint i;
+
+  for (i = 0; i < MAX_ICONS; i++)
+    {
+      if ((icon_info = priv->icons[i]) != NULL)
+        {
+          if (icon_info->pixbuf != NULL && icon_info->window != NULL)
+            gdk_window_hide (icon_info->window);
+        }
+    }
+
+  gdk_window_hide (priv->text_area);
+
+  GTK_WIDGET_CLASS (gtk_entry_parent_class)->unmap (widget);
+}
+
+static void
+gtk_entry_realize (GtkWidget *widget)
+{
+  GtkEntry *entry;
+  GtkEntryPrivate *priv;
+  EntryIconInfo *icon_info;
+  GdkWindow *window;
+  GdkWindowAttr attributes;
+  gint attributes_mask;
+  gint frame_x, frame_y;
+  int i;
+
+  gtk_widget_set_realized (widget, TRUE);
+  window = gtk_widget_get_parent_window (widget);
+  gtk_widget_set_window (widget, window);
+  g_object_ref (window);
+
+  entry = GTK_ENTRY (widget);
+  priv = entry->priv;
+
+  attributes.window_type = GDK_WINDOW_CHILD;
+  attributes.wclass = GDK_INPUT_ONLY;
+  attributes.event_mask = gtk_widget_get_events (widget);
+  attributes.event_mask |= (GDK_BUTTON_PRESS_MASK |
+                           GDK_BUTTON_RELEASE_MASK |
+                           GDK_BUTTON1_MOTION_MASK |
+                           GDK_BUTTON3_MOTION_MASK |
+                           GDK_POINTER_MOTION_HINT_MASK |
+                           GDK_POINTER_MOTION_MASK |
+                            GDK_ENTER_NOTIFY_MASK |
+                           GDK_LEAVE_NOTIFY_MASK);
+  attributes_mask = GDK_WA_X | GDK_WA_Y;
+
+  get_text_area_size (entry, &attributes.x, &attributes.y, &attributes.width, &attributes.height);
 
-  widget->style = gtk_style_attach (widget->style, widget->window);
+  get_frame_size (entry, &frame_x, &frame_y, NULL, NULL);
+  attributes.x += frame_x;
+  attributes.y += frame_y;
 
-  gdk_window_set_background (widget->window, &widget->style->base[GTK_WIDGET_STATE (widget)]);
-  gdk_window_set_background (entry->text_area, &widget->style->base[GTK_WIDGET_STATE (widget)]);
+  if (gtk_widget_is_sensitive (widget))
+    {
+      attributes.cursor = gdk_cursor_new_for_display (gtk_widget_get_display (widget), GDK_XTERM);
+      attributes_mask |= GDK_WA_CURSOR;
+    }
 
-  gdk_window_show (entry->text_area);
+  priv->text_area = gdk_window_new (gtk_widget_get_window (widget),
+                                    &attributes,
+                                    attributes_mask);
 
-  gtk_im_context_set_client_window (entry->im_context, entry->text_area);
+  gdk_window_set_user_data (priv->text_area, entry);
+
+  if (attributes_mask & GDK_WA_CURSOR)
+    g_object_unref (attributes.cursor);
+
+  gtk_im_context_set_client_window (priv->im_context, priv->text_area);
 
   gtk_entry_adjust_scroll (entry);
   gtk_entry_update_primary_selection (entry);
+
+
+  /* If the icon positions are already setup, create their windows.
+   * Otherwise if they don't exist yet, then construct_icon_info()
+   * will create the windows once the widget is already realized.
+   */
+  for (i = 0; i < MAX_ICONS; i++)
+    {
+      if ((icon_info = priv->icons[i]) != NULL)
+        {
+          if (icon_info->window == NULL)
+            realize_icon_info (widget, i);
+        }
+    }
 }
 
 static void
 gtk_entry_unrealize (GtkWidget *widget)
 {
   GtkEntry *entry = GTK_ENTRY (widget);
+  GtkEntryPrivate *priv = entry->priv;
   GtkClipboard *clipboard;
+  EntryIconInfo *icon_info;
+  gint i;
 
   gtk_entry_reset_layout (entry);
   
-  gtk_im_context_set_client_window (entry->im_context, NULL);
+  gtk_im_context_set_client_window (priv->im_context, NULL);
 
   clipboard = gtk_widget_get_clipboard (widget, GDK_SELECTION_PRIMARY);
   if (gtk_clipboard_get_owner (clipboard) == G_OBJECT (entry))
     gtk_clipboard_clear (clipboard);
   
-  if (entry->text_area)
+  if (priv->text_area)
     {
-      gdk_window_set_user_data (entry->text_area, NULL);
-      gdk_window_destroy (entry->text_area);
-      entry->text_area = NULL;
+      gdk_window_set_user_data (priv->text_area, NULL);
+      gdk_window_destroy (priv->text_area);
+      priv->text_area = NULL;
     }
 
-  if (entry->popup_menu)
+  if (priv->popup_menu)
     {
-      gtk_widget_destroy (entry->popup_menu);
-      entry->popup_menu = NULL;
+      gtk_widget_destroy (priv->popup_menu);
+      priv->popup_menu = NULL;
     }
 
   GTK_WIDGET_CLASS (gtk_entry_parent_class)->unrealize (widget);
+
+  for (i = 0; i < MAX_ICONS; i++)
+    {
+      if ((icon_info = priv->icons[i]) != NULL)
+        {
+          if (icon_info->window != NULL)
+            {
+              gdk_window_destroy (icon_info->window);
+              icon_info->window = NULL;
+            }
+        }
+    }
 }
 
 void
@@ -1504,13 +2935,19 @@ _gtk_entry_get_borders (GtkEntry *entry,
                        gint     *xborder,
                        gint     *yborder)
 {
+  GtkEntryPrivate *priv = entry->priv;
   GtkWidget *widget = GTK_WIDGET (entry);
-  GtkEntryPrivate *priv = GTK_ENTRY_GET_PRIVATE (widget);
 
-  if (entry->has_frame)
+  if (priv->has_frame)
     {
-      *xborder = widget->style->xthickness;
-      *yborder = widget->style->ythickness;
+      GtkStyleContext *context;
+      GtkBorder padding;
+
+      context = gtk_widget_get_style_context (widget);
+      gtk_style_context_get_padding (context, 0, &padding);
+
+      *xborder = padding.left;
+      *yborder = padding.top;
     }
   else
     {
@@ -1526,58 +2963,141 @@ _gtk_entry_get_borders (GtkEntry *entry,
 }
 
 static void
-gtk_entry_size_request (GtkWidget      *widget,
-                       GtkRequisition *requisition)
+gtk_entry_get_preferred_width (GtkWidget *widget,
+                               gint      *minimum,
+                               gint      *natural)
 {
   GtkEntry *entry = GTK_ENTRY (widget);
+  GtkEntryPrivate *priv = entry->priv;
   PangoFontMetrics *metrics;
   gint xborder, yborder;
   GtkBorder inner_border;
   PangoContext *context;
-  
-  gtk_widget_ensure_style (widget);
+  GtkStyleContext *style_context;
+  GtkStateFlags state;
+  gint icon_widths = 0;
+  gint icon_width, i;
+  gint width;
+
   context = gtk_widget_get_pango_context (widget);
+
+  style_context = gtk_widget_get_style_context (widget);
+  state = gtk_widget_get_state_flags (widget);
+
   metrics = pango_context_get_metrics (context,
-                                      widget->style->font_desc,
-                                      pango_context_get_language (context));
+                                       gtk_style_context_get_font (style_context, state),
+                                       pango_context_get_language (context));
 
-  entry->ascent = pango_font_metrics_get_ascent (metrics);
-  entry->descent = pango_font_metrics_get_descent (metrics);
-  
   _gtk_entry_get_borders (entry, &xborder, &yborder);
   _gtk_entry_effective_inner_border (entry, &inner_border);
 
-  if (entry->width_chars < 0)
-    requisition->width = MIN_ENTRY_WIDTH + xborder * 2 + inner_border.left + inner_border.right;
+  if (priv->width_chars < 0)
+    width = MIN_ENTRY_WIDTH + xborder * 2 + inner_border.left + inner_border.right;
   else
     {
       gint char_width = pango_font_metrics_get_approximate_char_width (metrics);
       gint digit_width = pango_font_metrics_get_approximate_digit_width (metrics);
       gint char_pixels = (MAX (char_width, digit_width) + PANGO_SCALE - 1) / PANGO_SCALE;
-      
-      requisition->width = char_pixels * entry->width_chars + xborder * 2 + inner_border.left + inner_border.right;
+
+      width = char_pixels * priv->width_chars + xborder * 2 + inner_border.left + inner_border.right;
+    }
+
+  for (i = 0; i < MAX_ICONS; i++)
+    {
+      icon_width = get_icon_width (entry, i);
+      if (icon_width > 0)
+        icon_widths += icon_width + 2 * priv->icon_margin;
     }
-    
-  requisition->height = PANGO_PIXELS (entry->ascent + entry->descent) + yborder * 2 + inner_border.top + inner_border.bottom;
+
+  if (icon_widths > width)
+    width += icon_widths;
 
   pango_font_metrics_unref (metrics);
+
+  *minimum = width;
+  *natural = width;
 }
 
 static void
-get_text_area_size (GtkEntry *entry,
-                    gint     *x,
-                    gint     *y,
-                    gint     *width,
-                    gint     *height)
+gtk_entry_get_preferred_height (GtkWidget *widget,
+                                gint      *minimum,
+                                gint      *natural)
 {
-  GtkEntryClass *class;
+  GtkEntry *entry = GTK_ENTRY (widget);
+  GtkEntryPrivate *priv = entry->priv;
+  PangoFontMetrics *metrics;
+  gint xborder, yborder;
+  GtkBorder inner_border;
+  GtkStyleContext *style_context;
+  GtkStateFlags state;
+  PangoContext *context;
+  gint height;
 
-  g_return_if_fail (GTK_IS_ENTRY (entry));
+  context = gtk_widget_get_pango_context (widget);
 
-  class = GTK_ENTRY_GET_CLASS (entry);
+  style_context = gtk_widget_get_style_context (widget);
+  state = gtk_widget_get_state_flags (widget);
 
-  if (class->get_text_area_size)
-    class->get_text_area_size (entry, x, y, width, height);
+  metrics = pango_context_get_metrics (context,
+                                       gtk_style_context_get_font (style_context, state),
+                                      pango_context_get_language (context));
+
+  priv->ascent = pango_font_metrics_get_ascent (metrics);
+  priv->descent = pango_font_metrics_get_descent (metrics);
+
+  _gtk_entry_get_borders (entry, &xborder, &yborder);
+  _gtk_entry_effective_inner_border (entry, &inner_border);
+
+  height = PANGO_PIXELS (priv->ascent + priv->descent) + yborder * 2 + inner_border.top + inner_border.bottom;
+
+  pango_font_metrics_unref (metrics);
+
+  *minimum = height;
+  *natural = height;
+}
+
+static void
+place_windows (GtkEntry *entry)
+{
+  GtkWidget *widget = GTK_WIDGET (entry);
+  GtkEntryPrivate *priv = entry->priv;
+  gint x, y, width, height;
+  gint frame_x, frame_y;
+  GtkAllocation primary;
+  GtkAllocation secondary;
+  EntryIconInfo *icon_info = NULL;
+
+  get_frame_size (entry, &frame_x, &frame_y, NULL, NULL);
+  get_text_area_size (entry, &x, &y, &width, &height);
+  get_icon_allocations (entry, &primary, &secondary);
+
+  if (gtk_widget_has_focus (widget) && !priv->interior_focus)
+    y += priv->focus_width;
+
+  if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
+    x += secondary.width;
+  else
+    x += primary.width;
+  width -= primary.width + secondary.width;
+
+  x += frame_x;
+  y += frame_y;
+  primary.x += frame_x;
+  primary.y += frame_y;
+  secondary.x += frame_x;
+  secondary.y += frame_y;
+
+  if ((icon_info = priv->icons[GTK_ENTRY_ICON_PRIMARY]) != NULL)
+    gdk_window_move_resize (icon_info->window,
+                            primary.x, primary.y,
+                            primary.width, primary.height);
+
+  if ((icon_info = priv->icons[GTK_ENTRY_ICON_SECONDARY]) != NULL)
+    gdk_window_move_resize (icon_info->window,
+                            secondary.x, secondary.y,
+                            secondary.width, secondary.height);
+
+  gdk_window_move_resize (priv->text_area, x, y, width, height);
 }
 
 static void
@@ -1587,22 +3107,24 @@ gtk_entry_get_text_area_size (GtkEntry *entry,
                              gint     *width,
                              gint     *height)
 {
+  GtkEntryPrivate *priv = entry->priv;
+  GtkWidget *widget = GTK_WIDGET (entry);
+  GtkAllocation allocation;
+  GtkRequisition requisition;
   gint frame_height;
   gint xborder, yborder;
-  GtkRequisition requisition;
-  GtkWidget *widget = GTK_WIDGET (entry);
-  GtkEntryPrivate *priv = GTK_ENTRY_GET_PRIVATE (widget);
 
-  gtk_widget_get_child_requisition (widget, &requisition);
+  gtk_widget_get_preferred_size (widget, &requisition, NULL);
+  gtk_widget_get_allocation (widget, &allocation);
   _gtk_entry_get_borders (entry, &xborder, &yborder);
 
-  if (GTK_WIDGET_REALIZED (widget))
-    gdk_drawable_get_size (widget->window, NULL, &frame_height);
+  if (gtk_widget_get_realized (widget))
+    get_frame_size (entry, NULL, NULL, NULL, &frame_height);
   else
     frame_height = requisition.height;
 
-  if (GTK_WIDGET_HAS_FOCUS (widget) && !priv->interior_focus)
-      frame_height -= 2 * priv->focus_width;
+  if (gtk_widget_has_focus (widget) && !priv->interior_focus)
+    frame_height -= 2 * priv->focus_width;
 
   if (x)
     *x = xborder;
@@ -1611,42 +3133,63 @@ gtk_entry_get_text_area_size (GtkEntry *entry,
     *y = frame_height / 2 - (requisition.height - yborder * 2) / 2;
 
   if (width)
-    *width = GTK_WIDGET (entry)->allocation.width - xborder * 2;
+    *width = allocation.width - xborder * 2;
 
   if (height)
     *height = requisition.height - yborder * 2;
 }
 
 static void
-get_widget_window_size (GtkEntry *entry,
-                        gint     *x,
-                        gint     *y,
-                        gint     *width,
-                        gint     *height)
+get_text_area_size (GtkEntry *entry,
+                    gint     *x,
+                    gint     *y,
+                    gint     *width,
+                    gint     *height)
 {
+  GtkEntryClass *class;
+
+  g_return_if_fail (GTK_IS_ENTRY (entry));
+
+  class = GTK_ENTRY_GET_CLASS (entry);
+
+  if (class->get_text_area_size)
+    class->get_text_area_size (entry, x, y, width, height);
+}
+
+
+static void
+get_frame_size (GtkEntry *entry,
+                gint     *x,
+                gint     *y,
+                gint     *width,
+                gint     *height)
+{
+  GtkEntryPrivate *priv = entry->priv;
+  GtkAllocation allocation;
   GtkRequisition requisition;
   GtkWidget *widget = GTK_WIDGET (entry);
-      
-  gtk_widget_get_child_requisition (widget, &requisition);
+
+  gtk_widget_get_preferred_size (widget, &requisition, NULL);
+  gtk_widget_get_allocation (widget, &allocation);
 
   if (x)
-    *x = widget->allocation.x;
+    *x = allocation.x;
 
   if (y)
     {
-      if (entry->is_cell_renderer)
-       *y = widget->allocation.y;
+      if (priv->is_cell_renderer)
+       *y = allocation.y;
       else
-       *y = widget->allocation.y + (widget->allocation.height - requisition.height) / 2;
+       *y = allocation.y + (allocation.height - requisition.height) / 2;
     }
 
   if (width)
-    *width = widget->allocation.width;
+    *width = allocation.width;
 
   if (height)
     {
-      if (entry->is_cell_renderer)
-       *height = widget->allocation.height;
+      if (priv->is_cell_renderer)
+       *height = allocation.height;
       else
        *height = requisition.height;
     }
@@ -1683,110 +3226,382 @@ gtk_entry_size_allocate (GtkWidget     *widget,
                         GtkAllocation *allocation)
 {
   GtkEntry *entry = GTK_ENTRY (widget);
-  
-  widget->allocation = *allocation;
-  
-  if (GTK_WIDGET_REALIZED (widget))
-    {
-      /* We call gtk_widget_get_child_requisition, since we want (for
-       * backwards compatibility reasons) the realization here to
-       * be affected by the usize of the entry, if set
-       */
-      gint x, y, width, height;
-      GtkEntryCompletion* completion;
 
-      get_widget_window_size (entry, &x, &y, &width, &height);
-      
-      gdk_window_move_resize (widget->window,
-                              x, y, width, height);   
+  gtk_widget_set_allocation (widget, allocation);
 
-      get_text_area_size (entry, &x, &y, &width, &height);
-      
-      gdk_window_move_resize (entry->text_area,
-                              x, y, width, height);
+  if (gtk_widget_get_realized (widget))
+    {
+      GtkEntryCompletion* completion;
 
+      place_windows (entry);
       gtk_entry_recompute (entry);
 
       completion = gtk_entry_get_completion (entry);
-      if (completion && GTK_WIDGET_MAPPED (completion->priv->popup_window))
+      if (completion && gtk_widget_get_mapped (completion->priv->popup_window))
         _gtk_entry_completion_resize_popup (completion);
     }
 }
 
-static void
-gtk_entry_draw_frame (GtkWidget    *widget,
-                      GdkRectangle *area)
+static gboolean
+should_prelight (GtkEntry             *entry,
+                 GtkEntryIconPosition  icon_pos)
 {
-  GtkEntryPrivate *priv = GTK_ENTRY_GET_PRIVATE (widget);
-  gint x = 0, y = 0, width, height;
-
-  gdk_drawable_get_size (widget->window, &width, &height);
-
-  /* Fix a problem with some themes which assume that entry->text_area's
-   * width equals widget->window's width */
-  if (GTK_IS_SPIN_BUTTON (widget))
-    {
-      gint xborder, yborder;
+  GtkEntryPrivate *priv = entry->priv;
+  EntryIconInfo *icon_info = priv->icons[icon_pos];
+  gboolean prelight;
 
-      get_text_area_size (GTK_ENTRY (widget), &x, NULL, &width, NULL);
-      _gtk_entry_get_borders (GTK_ENTRY (widget), &xborder, &yborder);
+  if (!icon_info)
+    return FALSE;
 
-      x -= xborder;
-      width += xborder * 2;
-    }
+  if (icon_info->nonactivatable && icon_info->target_list == NULL)
+    return FALSE;
 
-  if (GTK_WIDGET_HAS_FOCUS (widget) && !priv->interior_focus)
-    {
-      x += priv->focus_width;
-      y += priv->focus_width;
-      width -= 2 * priv->focus_width;
-      height -= 2 * priv->focus_width;
-    }
+  if (icon_info->pressed)
+    return FALSE;
 
-  gtk_paint_shadow (widget->style, widget->window,
-                   GTK_STATE_NORMAL, priv->shadow_type,
-                   area, widget, "entry", x, y, width, height);
+  gtk_widget_style_get (GTK_WIDGET (entry),
+                        "icon-prelight", &prelight,
+                        NULL);
 
-  if (GTK_WIDGET_HAS_FOCUS (widget) && !priv->interior_focus)
-    {
-      x -= priv->focus_width;
-      y -= priv->focus_width;
-      width += 2 * priv->focus_width;
-      height += 2 * priv->focus_width;
-      
-      gtk_paint_focus (widget->style, widget->window, GTK_WIDGET_STATE (widget), 
-                      area, widget, "entry",
-                      0, 0, width, height);
-    }
+  return prelight;
 }
 
-static gint
-gtk_entry_expose (GtkWidget      *widget,
-                 GdkEventExpose *event)
+static void
+draw_icon (GtkWidget            *widget,
+           cairo_t              *cr,
+           GtkEntryIconPosition  icon_pos)
 {
   GtkEntry *entry = GTK_ENTRY (widget);
+  GtkEntryPrivate *priv = entry->priv;
+  EntryIconInfo *icon_info = priv->icons[icon_pos];
+  GdkPixbuf *pixbuf;
+  gint x, y, width, height;
+  GtkStyleContext *context;
+  GtkIconSource *icon_source;
+  GtkStateFlags state;
+
+  if (!icon_info)
+    return;
 
-  if (widget->window == event->window)
-    gtk_entry_draw_frame (widget, &event->area);
-  else if (entry->text_area == event->window)
-    {
-      gint area_width, area_height;
-      gdk_drawable_get_size (entry->text_area, &area_width, &area_height);
+  gtk_entry_ensure_pixbuf (entry, icon_pos);
 
-      gtk_paint_flat_box (widget->style, entry->text_area, 
-                         GTK_WIDGET_STATE(widget), GTK_SHADOW_NONE,
-                         &event->area, widget, "entry_bg",
-                         0, 0, area_width, area_height);
+  if (icon_info->pixbuf == NULL)
+    return;
+
+  width = gdk_window_get_width (icon_info->window);
+  height = gdk_window_get_height (icon_info->window);
+
+  /* size_allocate hasn't been called yet. These are the default values.
+   */
+  if (width == 1 || height == 1)
+    return;
+
+  pixbuf = icon_info->pixbuf;
+  g_object_ref (pixbuf);
+
+  if (gdk_pixbuf_get_height (pixbuf) > height)
+    {
+      GdkPixbuf *temp_pixbuf;
+      gint scale;
+
+      scale = height - 2 * priv->icon_margin;
+      temp_pixbuf = gdk_pixbuf_scale_simple (pixbuf, scale, scale,
+                                             GDK_INTERP_BILINEAR);
+      g_object_unref (pixbuf);
+      pixbuf = temp_pixbuf;
+    }
+
+  x = (width  - gdk_pixbuf_get_width (pixbuf)) / 2;
+  y = (height - gdk_pixbuf_get_height (pixbuf)) / 2;
+
+  icon_source = gtk_icon_source_new ();
+  gtk_icon_source_set_pixbuf (icon_source, pixbuf);
+  gtk_icon_source_set_state_wildcarded (icon_source, TRUE);
+
+  state = 0;
+  if (!gtk_widget_is_sensitive (widget) || icon_info->insensitive)
+    state |= GTK_STATE_FLAG_INSENSITIVE;
+  else if (icon_info->prelight)
+    state |= GTK_STATE_FLAG_PRELIGHT;
+
+  context = gtk_widget_get_style_context (widget);
+  gtk_style_context_save (context);
+  gtk_style_context_set_state (context, state);
+  pixbuf = gtk_render_icon_pixbuf (context, icon_source, (GtkIconSize)-1);
+  gtk_style_context_restore (context);
+
+  gtk_icon_source_free (icon_source);
+
+  gdk_cairo_set_source_pixbuf (cr, pixbuf, x, y);
+  cairo_paint (cr);
+
+  g_object_unref (pixbuf);
+}
+
+
+static void
+gtk_entry_draw_frame (GtkWidget       *widget,
+                      GtkStyleContext *context,
+                      cairo_t         *cr)
+{
+  GtkEntry *entry = GTK_ENTRY (widget);
+  GtkEntryPrivate *priv = entry->priv;
+  gint x = 0, y = 0, width, height;
+  GtkAllocation allocation;
+  gint frame_x, frame_y;
+
+  cairo_save (cr);
+
+  get_frame_size (GTK_ENTRY (widget), &frame_x, &frame_y, &width, &height);
+  gtk_widget_get_allocation (widget, &allocation);
+
+  cairo_translate (cr, frame_x - allocation.x, frame_y - allocation.y);
+
+  /* Fix a problem with some themes which assume that entry->text_area's
+   * width equals widget->window's width
+   * http://bugzilla.gnome.org/show_bug.cgi?id=466000 */
+  if (GTK_IS_SPIN_BUTTON (widget))
+    {
+      gint xborder, yborder;
+
+      gtk_entry_get_text_area_size (GTK_ENTRY (widget), &x, NULL, &width, NULL);
+      _gtk_entry_get_borders (GTK_ENTRY (widget), &xborder, &yborder);
+
+      x -= xborder;
+      width += xborder * 2;
+    }
+
+  if (gtk_widget_has_focus (widget) && !priv->interior_focus)
+    {
+      x += priv->focus_width;
+      y += priv->focus_width;
+      width -= 2 * priv->focus_width;
+      height -= 2 * priv->focus_width;
+    }
+
+  gtk_render_background (context, cr,
+                         x, y, width, height);
+
+  if (priv->has_frame)
+    gtk_render_frame (context, cr,
+                      x, y, width, height);
+
+  gtk_entry_draw_progress (widget, context, cr);
+
+  if (gtk_widget_has_focus (widget) && !priv->interior_focus)
+    {
+      x -= priv->focus_width;
+      y -= priv->focus_width;
+      width += 2 * priv->focus_width;
+      height += 2 * priv->focus_width;
+
+      gtk_render_focus (context, cr,
+                        0, 0, width, height);
+    }
+
+  cairo_restore (cr);
+}
+
+static void
+get_progress_area (GtkWidget *widget,
+                   gint       *x,
+                   gint       *y,
+                   gint       *width,
+                   gint       *height)
+{
+  GtkEntry *entry = GTK_ENTRY (widget);
+  GtkEntryPrivate *private = entry->priv;
+  GtkBorder *progress_border;
+
+  get_text_area_size (entry, x, y, width, height);
+
+  if (!private->interior_focus)
+    {
+      *x -= private->focus_width;
+      *y -= private->focus_width;
+      *width += 2 * private->focus_width;
+      *height += 2 * private->focus_width;
+    }
+
+  gtk_widget_style_get (widget, "progress-border", &progress_border, NULL);
+
+  if (progress_border)
+    {
+      *x += progress_border->left;
+      *y += progress_border->top;
+      *width -= progress_border->left + progress_border->right;
+      *height -= progress_border->top + progress_border->bottom;
+
+      gtk_border_free (progress_border);
+    }
+
+  if (private->progress_pulse_mode)
+    {
+      gdouble value = private->progress_pulse_current;
+
+      *x += (gint) floor(value * (*width));
+      *width = (gint) ceil(private->progress_pulse_fraction * (*width));
+    }
+  else if (private->progress_fraction > 0)
+    {
+      gdouble value = private->progress_fraction;
+
+      if (gtk_widget_get_direction (GTK_WIDGET (entry)) == GTK_TEXT_DIR_RTL)
+        {
+          gint bar_width;
+
+          bar_width = floor(value * (*width) + 0.5);
+          *x += *width - bar_width;
+          *width = bar_width;
+        }
+      else
+        {
+          *width = (gint) floor(value * (*width) + 0.5);
+        }
+    }
+  else
+    {
+      *width = 0;
+      *height = 0;
+    }
+}
+
+static void
+gtk_entry_draw_progress (GtkWidget       *widget,
+                         GtkStyleContext *context,
+                         cairo_t         *cr)
+{
+  gint x, y, width, height;
+
+  get_progress_area (widget, &x, &y, &width, &height);
+
+  if ((width <= 0) || (height <= 0))
+    return;
+
+  gtk_style_context_save (context);
+  gtk_style_context_add_class (context, GTK_STYLE_CLASS_PROGRESSBAR);
+
+  gtk_render_activity (context, cr,
+                       x, y, width, height);
 
-      if (entry->dnd_position != -1)
-       gtk_entry_draw_cursor (GTK_ENTRY (widget), CURSOR_DND);
+  gtk_style_context_restore (context);
+}
+
+static gint
+gtk_entry_draw (GtkWidget *widget,
+               cairo_t   *cr)
+{
+  GtkEntry *entry = GTK_ENTRY (widget);
+  GtkStyleContext *context;
+  GtkStateFlags state;
+  GtkEntryPrivate *priv = entry->priv;
+  int i;
+
+  context = gtk_widget_get_style_context (widget);
+  state = gtk_widget_get_state_flags (widget);
+
+  gtk_style_context_save (context);
+  gtk_style_context_set_state (context, state);
+
+  if (gtk_cairo_should_draw_window (cr, gtk_widget_get_window (widget)))
+    {
+      /* Draw entry_bg, shadow, progress and focus */
+      gtk_entry_draw_frame (widget, context, cr);
+
+      /* Draw text and cursor */
+      cairo_save (cr);
+
+      gtk_cairo_transform_to_window (cr, widget, priv->text_area);
+
+      if (priv->dnd_position != -1)
+       gtk_entry_draw_cursor (GTK_ENTRY (widget), cr, CURSOR_DND);
       
-      gtk_entry_draw_text (GTK_ENTRY (widget));
+      gtk_entry_draw_text (GTK_ENTRY (widget), cr);
+
+      /* When no text is being displayed at all, don't show the cursor */
+      if (gtk_entry_get_display_mode (entry) != DISPLAY_BLANK &&
+         gtk_widget_has_focus (widget) &&
+         priv->selection_bound == priv->current_pos && priv->cursor_visible)
+        gtk_entry_draw_cursor (GTK_ENTRY (widget), cr, CURSOR_STANDARD);
+
+      cairo_restore (cr);
+
+      /* Draw icons */
+      for (i = 0; i < MAX_ICONS; i++)
+        {
+          EntryIconInfo *icon_info = priv->icons[i];
+
+          if (icon_info != NULL)
+            {
+              cairo_save (cr);
+
+              gtk_cairo_transform_to_window (cr, widget, icon_info->window);
+
+              draw_icon (widget, cr, i);
+
+              cairo_restore (cr);
+            }
+        }
+    }
+
+  gtk_style_context_restore (context);
+
+  return FALSE;
+}
+
+static gint
+gtk_entry_enter_notify (GtkWidget *widget,
+                        GdkEventCrossing *event)
+{
+  GtkEntry *entry = GTK_ENTRY (widget);
+  GtkEntryPrivate *priv = entry->priv;
+  gint i;
+
+  for (i = 0; i < MAX_ICONS; i++)
+    {
+      EntryIconInfo *icon_info = priv->icons[i];
+
+      if (icon_info != NULL && event->window == icon_info->window)
+        {
+          if (should_prelight (entry, i))
+            {
+              icon_info->prelight = TRUE;
+              gtk_widget_queue_draw (widget);
+            }
+
+          break;
+        }
+    }
+
+    return FALSE;
+}
+
+static gint
+gtk_entry_leave_notify (GtkWidget        *widget,
+                        GdkEventCrossing *event)
+{
+  GtkEntry *entry = GTK_ENTRY (widget);
+  GtkEntryPrivate *priv = entry->priv;
+  gint i;
+
+  for (i = 0; i < MAX_ICONS; i++)
+    {
+      EntryIconInfo *icon_info = priv->icons[i];
+
+      if (icon_info != NULL && event->window == icon_info->window)
+        {
+          /* a grab means that we may never see the button release */
+          if (event->mode == GDK_CROSSING_GRAB || event->mode == GDK_CROSSING_GTK_GRAB)
+            icon_info->pressed = FALSE;
+
+          if (should_prelight (entry, i))
+            {
+              icon_info->prelight = FALSE;
+              gtk_widget_queue_draw (widget);
+            }
 
-      if ((entry->visible || entry->invisible_char != 0) &&
-         GTK_WIDGET_HAS_FOCUS (widget) &&
-         entry->selection_bound == entry->current_pos && entry->cursor_visible)
-       gtk_entry_draw_cursor (GTK_ENTRY (widget), CURSOR_STANDARD);
+          break;
+        }
     }
 
   return FALSE;
@@ -1862,40 +3677,68 @@ gtk_entry_button_press (GtkWidget      *widget,
 {
   GtkEntry *entry = GTK_ENTRY (widget);
   GtkEditable *editable = GTK_EDITABLE (widget);
-  GtkEntryPrivate *priv = GTK_ENTRY_GET_PRIVATE (entry);
+  GtkEntryPrivate *priv = entry->priv;
+  EntryIconInfo *icon_info = NULL;
   gint tmp_pos;
   gint sel_start, sel_end;
+  gint i;
+
+  for (i = 0; i < MAX_ICONS; i++)
+    {
+      icon_info = priv->icons[i];
+
+      if (!icon_info || icon_info->insensitive)
+        continue;
+
+      if (event->window == icon_info->window)
+        {
+          if (should_prelight (entry, i))
+            {
+              icon_info->prelight = FALSE;
+              gtk_widget_queue_draw (widget);
+            }
+
+          priv->start_x = event->x;
+          priv->start_y = event->y;
+          icon_info->pressed = TRUE;
+
+          if (!icon_info->nonactivatable)
+            g_signal_emit (entry, signals[ICON_PRESS], 0, i, event);
+
+          return TRUE;
+        }
+    }
 
-  if (event->window != entry->text_area ||
-      (entry->button && event->button != entry->button))
+  if (event->window != priv->text_area ||
+      (priv->button && event->button != priv->button))
     return FALSE;
 
   gtk_entry_reset_blink_time (entry);
 
-  entry->button = event->button;
+  priv->button = event->button;
   
-  if (!GTK_WIDGET_HAS_FOCUS (widget))
+  if (!gtk_widget_has_focus (widget))
     {
-      entry->in_click = TRUE;
+      priv->in_click = TRUE;
       gtk_widget_grab_focus (widget);
-      entry->in_click = FALSE;
+      priv->in_click = FALSE;
     }
   
-  tmp_pos = gtk_entry_find_position (entry, event->x + entry->scroll_offset);
+  tmp_pos = gtk_entry_find_position (entry, event->x + priv->scroll_offset);
     
   if (event->button == 1)
     {
       gboolean have_selection = gtk_editable_get_selection_bounds (editable, &sel_start, &sel_end);
       
-      entry->select_words = FALSE;
-      entry->select_lines = FALSE;
+      priv->select_words = FALSE;
+      priv->select_lines = FALSE;
 
       if (event->state & GDK_SHIFT_MASK)
        {
          _gtk_entry_reset_im_context (entry);
          
          if (!have_selection) /* select from the current position to the clicked position */
-           sel_start = sel_end = entry->current_pos;
+           sel_start = sel_end = priv->current_pos;
          
          if (tmp_pos > sel_start && tmp_pos < sel_end)
            {
@@ -1918,12 +3761,12 @@ gtk_entry_button_press (GtkWidget      *widget,
                  break;
                  
                case GDK_2BUTTON_PRESS:
-                 entry->select_words = TRUE;
+                 priv->select_words = TRUE;
                  gtk_entry_select_word (entry);
                  break;
                  
                case GDK_3BUTTON_PRESS:
-                 entry->select_lines = TRUE;
+                 priv->select_lines = TRUE;
                  gtk_entry_select_line (entry);
                  break;
 
@@ -1931,10 +3774,10 @@ gtk_entry_button_press (GtkWidget      *widget,
                  break;
                }
 
-             start = MIN (entry->current_pos, entry->selection_bound);
+             start = MIN (priv->current_pos, priv->selection_bound);
              start = MIN (sel_start, start);
              
-             end = MAX (entry->current_pos, entry->selection_bound);
+             end = MAX (priv->current_pos, priv->selection_bound);
              end = MAX (sel_end, end);
 
              if (tmp_pos == sel_start || tmp_pos == sel_end)
@@ -1952,14 +3795,14 @@ gtk_entry_button_press (GtkWidget      *widget,
        switch (event->type)
        {
        case GDK_BUTTON_PRESS:
-         if (in_selection (entry, event->x + entry->scroll_offset))
+         if (in_selection (entry, event->x + priv->scroll_offset))
            {
              /* Click inside the selection - we'll either start a drag, or
               * clear the selection
               */
-             entry->in_drag = TRUE;
-             entry->drag_start_x = event->x + entry->scroll_offset;
-             entry->drag_start_y = event->y;
+             priv->in_drag = TRUE;
+             priv->drag_start_x = event->x + priv->scroll_offset;
+             priv->drag_start_y = event->y;
            }
          else
             gtk_editable_set_position (editable, tmp_pos);
@@ -1968,20 +3811,20 @@ gtk_entry_button_press (GtkWidget      *widget,
        case GDK_2BUTTON_PRESS:
          /* We ALWAYS receive a GDK_BUTTON_PRESS immediately before 
           * receiving a GDK_2BUTTON_PRESS so we need to reset
-          * entry->in_drag which may have been set above
+           * priv->in_drag which may have been set above
            */
-         entry->in_drag = FALSE;
-         entry->select_words = TRUE;
+         priv->in_drag = FALSE;
+         priv->select_words = TRUE;
          gtk_entry_select_word (entry);
          break;
        
        case GDK_3BUTTON_PRESS:
          /* We ALWAYS receive a GDK_BUTTON_PRESS immediately before
           * receiving a GDK_3BUTTON_PRESS so we need to reset
-          * entry->in_drag which may have been set above
+          * priv->in_drag which may have been set above
           */
-         entry->in_drag = FALSE;
-         entry->select_lines = TRUE;
+         priv->in_drag = FALSE;
+         priv->select_lines = TRUE;
          gtk_entry_select_line (entry);
          break;
 
@@ -1993,7 +3836,7 @@ gtk_entry_button_press (GtkWidget      *widget,
     }
   else if (event->button == 2 && event->type == GDK_BUTTON_PRESS)
     {
-      if (entry->editable)
+      if (priv->editable)
         {
           priv->insert_pos = tmp_pos;
           gtk_entry_paste (entry, GDK_SELECTION_PRIMARY);
@@ -2007,7 +3850,7 @@ gtk_entry_button_press (GtkWidget      *widget,
   else if (event->button == 3 && event->type == GDK_BUTTON_PRESS)
     {
       gtk_entry_do_popup (entry, event);
-      entry->button = 0;       /* Don't wait for release, since the menu will gtk_grab_add */
+      priv->button = 0;        /* Don't wait for release, since the menu will gtk_grab_add */
 
       return TRUE;
     }
@@ -2020,20 +3863,50 @@ gtk_entry_button_release (GtkWidget      *widget,
                          GdkEventButton *event)
 {
   GtkEntry *entry = GTK_ENTRY (widget);
+  GtkEntryPrivate *priv = entry->priv;
+  EntryIconInfo *icon_info = NULL;
+  gint i;
+
+  for (i = 0; i < MAX_ICONS; i++)
+    {
+      icon_info = priv->icons[i];
+
+      if (!icon_info || icon_info->insensitive)
+        continue;
+
+      if (event->window == icon_info->window)
+        {
+          icon_info->pressed = FALSE;
+
+          if (should_prelight (entry, i) &&
+              event->x >= 0 && event->y >= 0 &&
+              event->x < gdk_window_get_width (icon_info->window) &&
+              event->y < gdk_window_get_height (icon_info->window))
+            {
+              icon_info->prelight = TRUE;
+              gtk_widget_queue_draw (widget);
+            }
+
+          if (!icon_info->nonactivatable)
+            g_signal_emit (entry, signals[ICON_RELEASE], 0, i, event);
+
+          return TRUE;
+        }
+    }
 
-  if (event->window != entry->text_area || entry->button != event->button)
+  if (event->window != priv->text_area || priv->button != event->button)
     return FALSE;
 
-  if (entry->in_drag)
+  if (priv->in_drag)
     {
-      gint tmp_pos = gtk_entry_find_position (entry, entry->drag_start_x);
+      gint tmp_pos = gtk_entry_find_position (entry, priv->drag_start_x);
 
       gtk_editable_set_position (GTK_EDITABLE (entry), tmp_pos);
 
-      entry->in_drag = 0;
+      priv->in_drag = 0;
     }
   
-  entry->button = 0;
+  priv->button = 0;
   
   gtk_entry_update_primary_selection (entry);
              
@@ -2058,79 +3931,105 @@ gtk_entry_motion_notify (GtkWidget      *widget,
                         GdkEventMotion *event)
 {
   GtkEntry *entry = GTK_ENTRY (widget);
+  GtkEntryPrivate *priv = entry->priv;
+  EntryIconInfo *icon_info = NULL;
   gint tmp_pos;
+  gint i;
+
+  for (i = 0; i < MAX_ICONS; i++)
+    {
+      icon_info = priv->icons[i];
+
+      if (!icon_info || icon_info->insensitive)
+        continue;
+
+      if (event->window == icon_info->window)
+        {
+          if (icon_info->pressed &&
+              icon_info->target_list != NULL &&
+              gtk_drag_check_threshold (widget,
+                                        priv->start_x,
+                                        priv->start_y,
+                                        event->x,
+                                        event->y))
+            {
+              icon_info->in_drag = TRUE;
+              icon_info->pressed = FALSE;
+              gtk_drag_begin (widget,
+                              icon_info->target_list,
+                              icon_info->actions,
+                              1,
+                              (GdkEvent*)event);
+            }
+
+          return TRUE;
+        }
+    }
 
-  if (entry->mouse_cursor_obscured)
+  if (priv->mouse_cursor_obscured)
     {
       GdkCursor *cursor;
-      
+
       cursor = gdk_cursor_new_for_display (gtk_widget_get_display (widget), GDK_XTERM);
-      gdk_window_set_cursor (entry->text_area, cursor);
-      gdk_cursor_unref (cursor);
-      entry->mouse_cursor_obscured = FALSE;
+      gdk_window_set_cursor (priv->text_area, cursor);
+      g_object_unref (cursor);
+      priv->mouse_cursor_obscured = FALSE;
     }
 
-  if (event->window != entry->text_area || entry->button != 1)
+  if (event->window != priv->text_area || priv->button != 1)
     return FALSE;
 
-  if (entry->select_lines)
+  if (priv->select_lines)
     return TRUE;
 
   gdk_event_request_motions (event);
 
-  if (entry->in_drag)
+  if (priv->in_drag)
     {
-      if (entry->visible &&
+      if (gtk_entry_get_display_mode (entry) == DISPLAY_NORMAL &&
           gtk_drag_check_threshold (widget,
-                                    entry->drag_start_x, entry->drag_start_y,
-                                    event->x + entry->scroll_offset, event->y))
+                                    priv->drag_start_x, priv->drag_start_y,
+                                    event->x + priv->scroll_offset, event->y))
         {
           GdkDragContext *context;
           GtkTargetList  *target_list = gtk_target_list_new (NULL, 0);
-          guint actions = entry->editable ? GDK_ACTION_COPY | GDK_ACTION_MOVE : GDK_ACTION_COPY;
+          guint actions = priv->editable ? GDK_ACTION_COPY | GDK_ACTION_MOVE : GDK_ACTION_COPY;
           gchar *text = NULL;
-          GdkPixmap *pixmap = NULL;
+          cairo_surface_t *surface;
 
           gtk_target_list_add_text_targets (target_list, 0);
 
           text = _gtk_entry_get_selected_text (entry);
-          pixmap = _gtk_text_util_create_drag_icon (widget, text, -1);
+          surface = _gtk_text_util_create_drag_icon (widget, text, -1);
 
           context = gtk_drag_begin (widget, target_list, actions,
-                                    entry->button, (GdkEvent *)event);
+                                    priv->button, (GdkEvent *)event);
           
-          if (pixmap)
-            gtk_drag_set_icon_pixmap (context,
-                                      gdk_drawable_get_colormap (pixmap),
-                                      pixmap,
-                                      NULL,
-                                      -2, -2);
+          if (surface)
+            gtk_drag_set_icon_surface (context, surface);
           else
             gtk_drag_set_icon_default (context);
           
-          if (pixmap)
-            g_object_unref (pixmap);
+          if (surface)
+            cairo_surface_destroy (surface);
           g_free (text);
 
-          entry->in_drag = FALSE;
-          entry->button = 0;
+          priv->in_drag = FALSE;
+          priv->button = 0;
          
           gtk_target_list_unref (target_list);
         }
     }
   else
     {
-      gint height;
-      gdk_drawable_get_size (entry->text_area, NULL, &height);
-
       if (event->y < 0)
        tmp_pos = 0;
-      else if (event->y >= height)
-       tmp_pos = entry->text_length;
+      else if (event->y >= gdk_window_get_height (priv->text_area))
+       tmp_pos = gtk_entry_buffer_get_length (get_buffer (entry));
       else
-       tmp_pos = gtk_entry_find_position (entry, event->x + entry->scroll_offset);
-      
-      if (entry->select_words) 
+       tmp_pos = gtk_entry_find_position (entry, event->x + priv->scroll_offset);
+
+      if (priv->select_words)
        {
          gint min, max;
          gint old_min, old_max;
@@ -2138,12 +4037,12 @@ gtk_entry_motion_notify (GtkWidget      *widget,
          
          min = gtk_entry_move_backward_word (entry, tmp_pos, TRUE);
          max = gtk_entry_move_forward_word (entry, tmp_pos, TRUE);
-         
-         pos = entry->current_pos;
-         bound = entry->selection_bound;
 
-         old_min = MIN(entry->current_pos, entry->selection_bound);
-         old_max = MAX(entry->current_pos, entry->selection_bound);
+         pos = priv->current_pos;
+         bound = priv->selection_bound;
+
+         old_min = MIN(priv->current_pos, priv->selection_bound);
+         old_max = MAX(priv->current_pos, priv->selection_bound);
          
          if (min < old_min)
            {
@@ -2157,19 +4056,19 @@ gtk_entry_motion_notify (GtkWidget      *widget,
            }
          else if (pos == old_min) 
            {
-             if (entry->current_pos != min)
+             if (priv->current_pos != min)
                pos = max;
            }
          else 
            {
-             if (entry->current_pos != max)
+             if (priv->current_pos != max)
                pos = min;
            }
        
          gtk_entry_set_positions (entry, pos, bound);
        }
       else
-      gtk_entry_set_positions (entry, tmp_pos, -1);
+        gtk_entry_set_positions (entry, tmp_pos, -1);
     }
       
   return TRUE;
@@ -2178,39 +4077,28 @@ gtk_entry_motion_notify (GtkWidget      *widget,
 static void
 set_invisible_cursor (GdkWindow *window)
 {
-  GdkBitmap *empty_bitmap;
+  GdkDisplay *display;
   GdkCursor *cursor;
-  GdkColor useless;
-  char invisible_cursor_bits[] = { 0x0 };      
-       
-  useless.red = useless.green = useless.blue = 0;
-  useless.pixel = 0;
-  
-  empty_bitmap = gdk_bitmap_create_from_data (window,
-                                             invisible_cursor_bits,
-                                             1, 1);
-  
-  cursor = gdk_cursor_new_from_pixmap (empty_bitmap,
-                                      empty_bitmap,
-                                      &useless,
-                                      &useless, 0, 0);
-  
+
+  display = gdk_window_get_display (window);
+  cursor = gdk_cursor_new_for_display (display, GDK_BLANK_CURSOR);
+
   gdk_window_set_cursor (window, cursor);
-  
-  gdk_cursor_unref (cursor);
-  
-  g_object_unref (empty_bitmap);
+
+  g_object_unref (cursor);
 }
 
 static void
 gtk_entry_obscure_mouse_cursor (GtkEntry *entry)
 {
-  if (entry->mouse_cursor_obscured)
+  GtkEntryPrivate *priv = entry->priv;
+
+  if (priv->mouse_cursor_obscured)
     return;
 
-  set_invisible_cursor (entry->text_area);
-  
-  entry->mouse_cursor_obscured = TRUE;  
+  set_invisible_cursor (priv->text_area);
+
+  priv->mouse_cursor_obscured = TRUE;
 }
 
 static gint
@@ -2218,27 +4106,28 @@ gtk_entry_key_press (GtkWidget   *widget,
                     GdkEventKey *event)
 {
   GtkEntry *entry = GTK_ENTRY (widget);
+  GtkEntryPrivate *priv = entry->priv;
 
   gtk_entry_reset_blink_time (entry);
   gtk_entry_pend_cursor_blink (entry);
 
-  if (entry->editable)
+  if (priv->editable)
     {
-      if (gtk_im_context_filter_keypress (entry->im_context, event))
+      if (gtk_im_context_filter_keypress (priv->im_context, event))
        {
          gtk_entry_obscure_mouse_cursor (entry);
-         entry->need_im_reset = TRUE;
+         priv->need_im_reset = TRUE;
          return TRUE;
        }
     }
 
-  if (event->keyval == GDK_Return || 
-      event->keyval == GDK_KP_Enter || 
-      event->keyval == GDK_ISO_Enter || 
-      event->keyval == GDK_Escape)
+  if (event->keyval == GDK_KEY_Return || 
+      event->keyval == GDK_KEY_KP_Enter || 
+      event->keyval == GDK_KEY_ISO_Enter || 
+      event->keyval == GDK_KEY_Escape)
     {
       GtkEntryCompletion *completion = gtk_entry_get_completion (entry);
-      
+
       if (completion && completion->priv->completion_timeout)
         {
           g_source_remove (completion->priv->completion_timeout);
@@ -2253,7 +4142,7 @@ gtk_entry_key_press (GtkWidget   *widget,
      */
     return TRUE;
 
-  if (!entry->editable && event->length)
+  if (!priv->editable && event->length)
     gtk_widget_error_bell (widget);
 
   return FALSE;
@@ -2264,12 +4153,13 @@ gtk_entry_key_release (GtkWidget   *widget,
                       GdkEventKey *event)
 {
   GtkEntry *entry = GTK_ENTRY (widget);
+  GtkEntryPrivate *priv = entry->priv;
 
-  if (entry->editable)
+  if (priv->editable)
     {
-      if (gtk_im_context_filter_keypress (entry->im_context, event))
+      if (gtk_im_context_filter_keypress (priv->im_context, event))
        {
-         entry->need_im_reset = TRUE;
+         priv->need_im_reset = TRUE;
          return TRUE;
        }
     }
@@ -2282,16 +4172,17 @@ gtk_entry_focus_in (GtkWidget     *widget,
                    GdkEventFocus *event)
 {
   GtkEntry *entry = GTK_ENTRY (widget);
+  GtkEntryPrivate *priv = entry->priv;
   GdkKeymap *keymap;
 
   gtk_widget_queue_draw (widget);
 
   keymap = gdk_keymap_get_for_display (gtk_widget_get_display (widget));
 
-  if (entry->editable)
+  if (priv->editable)
     {
-      entry->need_im_reset = TRUE;
-      gtk_im_context_focus_in (entry->im_context);
+      priv->need_im_reset = TRUE;
+      gtk_im_context_focus_in (priv->im_context);
       keymap_state_changed (keymap, entry);
       g_signal_connect (keymap, "state-changed", 
                         G_CALLBACK (keymap_state_changed), entry);
@@ -2311,17 +4202,18 @@ gtk_entry_focus_out (GtkWidget     *widget,
                     GdkEventFocus *event)
 {
   GtkEntry *entry = GTK_ENTRY (widget);
+  GtkEntryPrivate *priv = entry->priv;
   GtkEntryCompletion *completion;
   GdkKeymap *keymap;
-  
+
   gtk_widget_queue_draw (widget);
 
   keymap = gdk_keymap_get_for_display (gtk_widget_get_display (widget));
 
-  if (entry->editable)
+  if (priv->editable)
     {
-      entry->need_im_reset = TRUE;
-      gtk_im_context_focus_out (entry->im_context);
+      priv->need_im_reset = TRUE;
+      gtk_im_context_focus_out (priv->im_context);
       remove_capslock_feedback (entry);
     }
 
@@ -2341,11 +4233,12 @@ static void
 gtk_entry_grab_focus (GtkWidget        *widget)
 {
   GtkEntry *entry = GTK_ENTRY (widget);
+  GtkEntryPrivate *priv = entry->priv;
   gboolean select_on_focus;
   
   GTK_WIDGET_CLASS (gtk_entry_parent_class)->grab_focus (widget);
 
-  if (entry->editable && !entry->in_click)
+  if (priv->editable && !priv->in_click)
     {
       g_object_get (gtk_widget_get_settings (widget),
                     "gtk-entry-select-on-focus",
@@ -2369,34 +4262,34 @@ gtk_entry_direction_changed (GtkWidget        *widget,
 }
 
 static void
-gtk_entry_state_changed (GtkWidget      *widget,
-                        GtkStateType    previous_state)
+gtk_entry_state_flags_changed (GtkWidget     *widget,
+                               GtkStateFlags  previous_state)
 {
   GtkEntry *entry = GTK_ENTRY (widget);
+  GtkEntryPrivate *priv = entry->priv;
   GdkCursor *cursor;
   
-  if (GTK_WIDGET_REALIZED (widget))
+  if (gtk_widget_get_realized (widget))
     {
-      gdk_window_set_background (widget->window, &widget->style->base[GTK_WIDGET_STATE (widget)]);
-      gdk_window_set_background (entry->text_area, &widget->style->base[GTK_WIDGET_STATE (widget)]);
-
-      if (GTK_WIDGET_IS_SENSITIVE (widget))
+      if (gtk_widget_is_sensitive (widget))
         cursor = gdk_cursor_new_for_display (gtk_widget_get_display (widget), GDK_XTERM);
       else 
         cursor = NULL;
-      
-      gdk_window_set_cursor (entry->text_area, cursor);
+
+      gdk_window_set_cursor (priv->text_area, cursor);
 
       if (cursor)
-        gdk_cursor_unref (cursor);
+        g_object_unref (cursor);
 
-      entry->mouse_cursor_obscured = FALSE;
+      priv->mouse_cursor_obscured = FALSE;
+
+      update_cursors (widget);
     }
 
-  if (!GTK_WIDGET_IS_SENSITIVE (widget))
+  if (!gtk_widget_is_sensitive (widget))
     {
       /* Clear any selection */
-      gtk_editable_select_region (GTK_EDITABLE (entry), entry->current_pos, entry->current_pos);      
+      gtk_editable_select_region (GTK_EDITABLE (entry), priv->current_pos, priv->current_pos);
     }
   
   gtk_widget_queue_draw (widget);
@@ -2417,30 +4310,14 @@ gtk_entry_insert_text (GtkEditable *editable,
                       gint         new_text_length,
                       gint        *position)
 {
-  GtkEntry *entry = GTK_ENTRY (editable);
-  gchar buf[64];
-  gchar *text;
-
-  if (*position < 0 || *position > entry->text_length)
-    *position = entry->text_length;
-  
   g_object_ref (editable);
-  
-  if (new_text_length <= 63)
-    text = buf;
-  else
-    text = g_new (gchar, new_text_length + 1);
-
-  text[new_text_length] = '\0';
-  strncpy (text, new_text, new_text_length);
 
-  g_signal_emit_by_name (editable, "insert-text", text, new_text_length, position);
-
-  if (!entry->visible)
-    trash_area (text, new_text_length);
+  /*
+   * The incoming text may a password or other secret. We make sure
+   * not to copy it into temporary buffers.
+   */
 
-  if (new_text_length > 63)
-    g_free (text);
+  g_signal_emit_by_name (editable, "insert-text", new_text, new_text_length, position);
 
   g_object_unref (editable);
 }
@@ -2450,15 +4327,6 @@ gtk_entry_delete_text (GtkEditable *editable,
                       gint         start_pos,
                       gint         end_pos)
 {
-  GtkEntry *entry = GTK_ENTRY (editable);
-
-  if (end_pos < 0 || end_pos > entry->text_length)
-    end_pos = entry->text_length;
-  if (start_pos < 0)
-    start_pos = 0;
-  if (start_pos > end_pos)
-    start_pos = end_pos;
-  
   g_object_ref (editable);
 
   g_signal_emit_by_name (editable, "delete-text", start_pos, end_pos);
@@ -2472,18 +4340,23 @@ gtk_entry_get_chars      (GtkEditable   *editable,
                          gint           end_pos)
 {
   GtkEntry *entry = GTK_ENTRY (editable);
+  const gchar *text;
+  gint text_length;
   gint start_index, end_index;
-  
+
+  text = gtk_entry_buffer_get_text (get_buffer (entry));
+  text_length = gtk_entry_buffer_get_length (get_buffer (entry));
+
   if (end_pos < 0)
-    end_pos = entry->text_length;
+    end_pos = text_length;
 
-  start_pos = MIN (entry->text_length, start_pos);
-  end_pos = MIN (entry->text_length, end_pos);
+  start_pos = MIN (text_length, start_pos);
+  end_pos = MIN (text_length, end_pos);
 
-  start_index = g_utf8_offset_to_pointer (entry->text, start_pos) - entry->text;
-  end_index = g_utf8_offset_to_pointer (entry->text, end_pos) - entry->text;
+  start_index = g_utf8_offset_to_pointer (text, start_pos) - text;
+  end_index = g_utf8_offset_to_pointer (text, end_pos) - text;
 
-  return g_strndup (entry->text + start_index, end_index - start_index);
+  return g_strndup (text + start_index, end_index - start_index);
 }
 
 static void
@@ -2491,12 +4364,16 @@ gtk_entry_real_set_position (GtkEditable *editable,
                             gint         position)
 {
   GtkEntry *entry = GTK_ENTRY (editable);
+  GtkEntryPrivate *priv = entry->priv;
 
-  if (position < 0 || position > entry->text_length)
-    position = entry->text_length;
+  guint length;
 
-  if (position != entry->current_pos ||
-      position != entry->selection_bound)
+  length = gtk_entry_buffer_get_length (get_buffer (entry));
+  if (position < 0 || position > length)
+    position = length;
+
+  if (position != priv->current_pos ||
+      position != priv->selection_bound)
     {
       _gtk_entry_reset_im_context (entry);
       gtk_entry_set_positions (entry, position, position);
@@ -2506,7 +4383,10 @@ gtk_entry_real_set_position (GtkEditable *editable,
 static gint
 gtk_entry_get_position (GtkEditable *editable)
 {
-  return GTK_ENTRY (editable)->current_pos;
+  GtkEntry *entry = GTK_ENTRY (editable);
+  GtkEntryPrivate *priv = entry->priv;
+
+  return priv->current_pos;
 }
 
 static void
@@ -2515,17 +4395,19 @@ gtk_entry_set_selection_bounds (GtkEditable *editable,
                                gint         end)
 {
   GtkEntry *entry = GTK_ENTRY (editable);
+  guint length;
 
+  length = gtk_entry_buffer_get_length (get_buffer (entry));
   if (start < 0)
-    start = entry->text_length;
+    start = length;
   if (end < 0)
-    end = entry->text_length;
+    end = length;
   
   _gtk_entry_reset_im_context (entry);
 
   gtk_entry_set_positions (entry,
-                          MIN (end, entry->text_length),
-                          MIN (start, entry->text_length));
+                          MIN (end, length),
+                          MIN (start, length));
 
   gtk_entry_update_primary_selection (entry);
 }
@@ -2536,40 +4418,73 @@ gtk_entry_get_selection_bounds (GtkEditable *editable,
                                gint        *end)
 {
   GtkEntry *entry = GTK_ENTRY (editable);
+  GtkEntryPrivate *priv = entry->priv;
 
-  *start = entry->selection_bound;
-  *end = entry->current_pos;
+  *start = priv->selection_bound;
+  *end = priv->current_pos;
 
-  return (entry->selection_bound != entry->current_pos);
+  return (priv->selection_bound != priv->current_pos);
 }
 
-static void 
-gtk_entry_style_set    (GtkWidget      *widget,
-                        GtkStyle       *previous_style)
+static void
+icon_theme_changed (GtkEntry *entry)
 {
-  GtkEntry *entry = GTK_ENTRY (widget);
-  GtkEntryPrivate *priv = GTK_ENTRY_GET_PRIVATE (entry);
-  gint focus_width;
-  gboolean interior_focus;
+  GtkEntryPrivate *priv = entry->priv;
+  gint i;
 
-  gtk_widget_style_get (widget,
-                       "focus-line-width", &focus_width,
-                       "interior-focus", &interior_focus,
-                       NULL);
+  for (i = 0; i < MAX_ICONS; i++)
+    {
+      EntryIconInfo *icon_info = priv->icons[i];
+      if (icon_info != NULL) 
+        {
+          if (icon_info->storage_type == GTK_IMAGE_ICON_NAME)
+            gtk_entry_set_icon_from_icon_name (entry, i, icon_info->icon_name);
+          else if (icon_info->storage_type == GTK_IMAGE_STOCK)
+            gtk_entry_set_icon_from_stock (entry, i, icon_info->stock_id);
+          else if (icon_info->storage_type == GTK_IMAGE_GICON)
+            gtk_entry_set_icon_from_gicon (entry, i, icon_info->gicon);
+        }
+    }
 
-  priv->focus_width = focus_width;
+  gtk_widget_queue_draw (GTK_WIDGET (entry));
+}
+
+static void
+icon_margin_changed (GtkEntry *entry)
+{
+  GtkEntryPrivate *priv = entry->priv;
+  GtkBorder border;
+
+  _gtk_entry_effective_inner_border (GTK_ENTRY (entry), &border);
+
+  priv->icon_margin = border.left;
+}
+
+static void 
+gtk_entry_style_updated (GtkWidget *widget)
+{
+  GtkEntry *entry = GTK_ENTRY (widget);
+  GtkEntryPrivate *priv = entry->priv;
+  gint focus_width;
+  gboolean interior_focus;
+
+  GTK_WIDGET_CLASS (gtk_entry_parent_class)->style_updated (widget);
+
+  gtk_widget_style_get (widget,
+                       "focus-line-width", &focus_width,
+                       "interior-focus", &interior_focus,
+                       NULL);
+
+  priv->focus_width = focus_width;
   priv->interior_focus = interior_focus;
 
   if (!priv->invisible_char_set)
-    entry->invisible_char = find_invisible_char (GTK_WIDGET (entry));
+    priv->invisible_char = find_invisible_char (GTK_WIDGET (entry));
 
   gtk_entry_recompute (entry);
 
-  if (previous_style && GTK_WIDGET_REALIZED (widget))
-    {
-      gdk_window_set_background (widget->window, &widget->style->base[GTK_WIDGET_STATE (widget)]);
-      gdk_window_set_background (entry->text_area, &widget->style->base[GTK_WIDGET_STATE (widget)]);
-    }
+  icon_theme_changed (entry);
+  icon_margin_changed (entry);
 }
 
 /* GtkCellEditable method implementations
@@ -2586,9 +4501,11 @@ gtk_cell_editable_key_press_event (GtkEntry    *entry,
                                   GdkEventKey *key_event,
                                   gpointer     data)
 {
-  if (key_event->keyval == GDK_Escape)
+  GtkEntryPrivate *priv = entry->priv;
+
+  if (key_event->keyval == GDK_KEY_Escape)
     {
-      entry->editing_canceled = TRUE;
+      priv->editing_canceled = TRUE;
       gtk_cell_editable_editing_done (GTK_CELL_EDITABLE (entry));
       gtk_cell_editable_remove_widget (GTK_CELL_EDITABLE (entry));
 
@@ -2596,7 +4513,7 @@ gtk_cell_editable_key_press_event (GtkEntry    *entry,
     }
 
   /* override focus */
-  if (key_event->keyval == GDK_Up || key_event->keyval == GDK_Down)
+  if (key_event->keyval == GDK_KEY_Up || key_event->keyval == GDK_KEY_Down)
     {
       gtk_cell_editable_editing_done (GTK_CELL_EDITABLE (entry));
       gtk_cell_editable_remove_widget (GTK_CELL_EDITABLE (entry));
@@ -2611,7 +4528,10 @@ static void
 gtk_entry_start_editing (GtkCellEditable *cell_editable,
                         GdkEvent        *event)
 {
-  GTK_ENTRY (cell_editable)->is_cell_renderer = TRUE;
+  GtkEntry *entry = GTK_ENTRY (cell_editable);
+  GtkEntryPrivate *priv = entry->priv;
+
+  priv->is_cell_renderer = TRUE;
 
   g_signal_connect (cell_editable, "activate",
                    G_CALLBACK (gtk_cell_editable_entry_activated), NULL);
@@ -2622,12 +4542,24 @@ gtk_entry_start_editing (GtkCellEditable *cell_editable,
 static void
 gtk_entry_password_hint_free (GtkEntryPasswordHint *password_hint)
 {
-  if (password_hint->password_hint_timeout_id)
-    g_source_remove (password_hint->password_hint_timeout_id);
+  if (password_hint->source_id)
+    g_source_remove (password_hint->source_id);
 
   g_slice_free (GtkEntryPasswordHint, password_hint);
 }
 
+
+static gboolean
+gtk_entry_remove_password_hint (gpointer data)
+{
+  GtkEntryPasswordHint *password_hint = g_object_get_qdata (data, quark_password_hint);
+  password_hint->position = -1;
+
+  /* Force the string to be redrawn, but now without a visible character */
+  gtk_entry_recompute (GTK_ENTRY (data));
+  return FALSE;
+}
+
 /* Default signal handlers
  */
 static void
@@ -2636,82 +4568,59 @@ gtk_entry_real_insert_text (GtkEditable *editable,
                            gint         new_text_length,
                            gint        *position)
 {
-  GtkEntry *entry = GTK_ENTRY (editable);
-  gint index;
+  guint n_inserted;
   gint n_chars;
 
-  if (new_text_length < 0)
-    new_text_length = strlen (new_text);
-
   n_chars = g_utf8_strlen (new_text, new_text_length);
-  if (entry->text_max_length > 0 && n_chars + entry->text_length > entry->text_max_length)
-    {
-      gtk_widget_error_bell (GTK_WIDGET (entry));
-      n_chars = entry->text_max_length - entry->text_length;
-      new_text_length = g_utf8_offset_to_pointer (new_text, n_chars) - new_text;
-    }
 
-  if (new_text_length + entry->n_bytes + 1 > entry->text_size)
-    {
-      gsize prev_size = entry->text_size;
+  /*
+   * The actual insertion into the buffer. This will end up firing the
+   * following signal handlers: buffer_inserted_text(), buffer_notify_display_text(),
+   * buffer_notify_text(), buffer_notify_length()
+   */
+  n_inserted = gtk_entry_buffer_insert_text (get_buffer (GTK_ENTRY (editable)), *position, new_text, n_chars);
 
-      while (new_text_length + entry->n_bytes + 1 > entry->text_size)
-       {
-         if (entry->text_size == 0)
-           entry->text_size = MIN_SIZE;
-         else
-           {
-             if (2 * (guint)entry->text_size < MAX_SIZE &&
-                 2 * (guint)entry->text_size > entry->text_size)
-               entry->text_size *= 2;
-             else
-               {
-                 entry->text_size = MAX_SIZE;
-                 if (new_text_length > (gint)entry->text_size - (gint)entry->n_bytes - 1)
-                   {
-                     new_text_length = (gint)entry->text_size - (gint)entry->n_bytes - 1;
-                     new_text_length = g_utf8_find_prev_char (new_text, new_text + new_text_length + 1) - new_text;
-                     n_chars = g_utf8_strlen (new_text, new_text_length);
-                   }
-                 break;
-               }
-           }
-       }
+  if (n_inserted != n_chars)
+      gtk_widget_error_bell (GTK_WIDGET (editable));
 
-      if (entry->visible)
-       entry->text = g_realloc (entry->text, entry->text_size);
-      else
-       {
-         /* Same thing, just slower and without leaving stuff in memory.  */
-         gchar *et_new = g_malloc (entry->text_size);
-         memcpy (et_new, entry->text, MIN (prev_size, entry->text_size));
-         trash_area (entry->text, prev_size);
-         g_free (entry->text);
-         entry->text = et_new;
-       }
-    }
+  *position += n_inserted;
+}
+
+static void
+gtk_entry_real_delete_text (GtkEditable *editable,
+                            gint         start_pos,
+                            gint         end_pos)
+{
+  /*
+   * The actual deletion from the buffer. This will end up firing the
+   * following signal handlers: buffer_deleted_text(), buffer_notify_display_text(),
+   * buffer_notify_text(), buffer_notify_length()
+   */
 
-  index = g_utf8_offset_to_pointer (entry->text, *position) - entry->text;
+  gtk_entry_buffer_delete_text (get_buffer (GTK_ENTRY (editable)), start_pos, end_pos - start_pos);
+}
 
-  g_memmove (entry->text + index + new_text_length, entry->text + index, entry->n_bytes - index);
-  memcpy (entry->text + index, new_text, new_text_length);
+/* GtkEntryBuffer signal handlers
+ */
+static void
+buffer_inserted_text (GtkEntryBuffer *buffer,
+                      guint           position,
+                      const gchar    *chars,
+                      guint           n_chars,
+                      GtkEntry       *entry)
+{
+  GtkEntryPrivate *priv = entry->priv;
+  guint password_hint_timeout;
 
-  entry->n_bytes += new_text_length;
-  entry->text_length += n_chars;
+  if (priv->current_pos > position)
+    priv->current_pos += n_chars;
 
-  /* NUL terminate for safety and convenience */
-  entry->text[entry->n_bytes] = '\0';
-  
-  if (entry->current_pos > *position)
-    entry->current_pos += n_chars;
-  
-  if (entry->selection_bound > *position)
-    entry->selection_bound += n_chars;
+  if (priv->selection_bound > position)
+    priv->selection_bound += n_chars;
 
-  if (n_chars == 1 && !entry->visible && (new_text_length < PASSWORD_HINT_MAX))
+  /* Calculate the password hint if it needs to be displayed. */
+  if (n_chars == 1 && !priv->visible)
     {
-      guint password_hint_timeout;
-
       g_object_get (gtk_widget_get_settings (GTK_WIDGET (entry)),
                     "gtk-entry-password-hint-timeout", &password_hint_timeout,
                     NULL);
@@ -2720,83 +4629,105 @@ gtk_entry_real_insert_text (GtkEditable *editable,
         {
           GtkEntryPasswordHint *password_hint = g_object_get_qdata (G_OBJECT (entry),
                                                                     quark_password_hint);
-
           if (!password_hint)
             {
               password_hint = g_slice_new0 (GtkEntryPasswordHint);
-              g_object_set_qdata_full (G_OBJECT (entry), quark_password_hint,
-                                       password_hint,
-                                       (GDestroyNotify) gtk_entry_password_hint_free);
+              g_object_set_qdata_full (G_OBJECT (entry), quark_password_hint, password_hint,
+                                       (GDestroyNotify)gtk_entry_password_hint_free);
             }
 
-          memset (&password_hint->password_hint, 0x0, PASSWORD_HINT_MAX);
-          password_hint->password_hint_length = new_text_length;
-          memcpy (&password_hint->password_hint, new_text, new_text_length);
-          password_hint->password_hint_position = *position + n_chars;
-       }
+          password_hint->position = position;
+          if (password_hint->source_id)
+            g_source_remove (password_hint->source_id);
+          password_hint->source_id = gdk_threads_add_timeout (password_hint_timeout,
+                                                              (GSourceFunc)gtk_entry_remove_password_hint, entry);
+        }
     }
-  else
+}
+
+static void
+buffer_deleted_text (GtkEntryBuffer *buffer,
+                     guint           position,
+                     guint           n_chars,
+                     GtkEntry       *entry)
+{
+  GtkEntryPrivate *priv = entry->priv;
+  guint end_pos = position + n_chars;
+  gint selection_bound;
+  guint current_pos;
+
+  current_pos = priv->current_pos;
+  if (current_pos > position)
+    current_pos -= MIN (current_pos, end_pos) - position;
+
+  selection_bound = priv->selection_bound;
+  if (selection_bound > position)
+    selection_bound -= MIN (selection_bound, end_pos) - position;
+
+  gtk_entry_set_positions (entry, current_pos, selection_bound);
+
+  /* We might have deleted the selection */
+  gtk_entry_update_primary_selection (entry);
+
+  /* Disable the password hint if one exists. */
+  if (!priv->visible)
     {
-      g_object_set_qdata (G_OBJECT (entry), quark_password_hint, NULL);
+      GtkEntryPasswordHint *password_hint = g_object_get_qdata (G_OBJECT (entry),
+                                                                quark_password_hint);
+      if (password_hint)
+        {
+          if (password_hint->source_id)
+            g_source_remove (password_hint->source_id);
+          password_hint->source_id = 0;
+          password_hint->position = -1;
+        }
     }
+}
 
-  *position += n_chars;
-
+static void
+buffer_notify_text (GtkEntryBuffer *buffer,
+                    GParamSpec     *spec,
+                    GtkEntry       *entry)
+{
   gtk_entry_recompute (entry);
-
   emit_changed (entry);
-  g_object_notify (G_OBJECT (editable), "text");
+  g_object_notify (G_OBJECT (entry), "text");
 }
 
 static void
-gtk_entry_real_delete_text (GtkEditable *editable,
-                           gint         start_pos,
-                           gint         end_pos)
+buffer_notify_length (GtkEntryBuffer *buffer,
+                      GParamSpec     *spec,
+                      GtkEntry       *entry)
 {
-  GtkEntry *entry = GTK_ENTRY (editable);
-
-  if (start_pos < 0)
-    start_pos = 0;
-  if (end_pos < 0 || end_pos > entry->text_length)
-    end_pos = entry->text_length;
-  
-  if (start_pos < end_pos)
-    {
-      gint start_index = g_utf8_offset_to_pointer (entry->text, start_pos) - entry->text;
-      gint end_index = g_utf8_offset_to_pointer (entry->text, end_pos) - entry->text;
-      gint current_pos;
-      gint selection_bound;
-
-      g_memmove (entry->text + start_index, entry->text + end_index, entry->n_bytes + 1 - end_index);
-      entry->text_length -= (end_pos - start_pos);
-      entry->n_bytes -= (end_index - start_index);
-
-      /* In password-mode, make sure we don't leave anything sensitive after
-       * the terminating zero.  Note, that the terminating zero already trashed
-       * one byte.
-       */
-      if (!entry->visible)
-       trash_area (entry->text + entry->n_bytes + 1, end_index - start_index - 1);
-      
-      current_pos = entry->current_pos;
-      if (current_pos > start_pos)
-       current_pos -= MIN (current_pos, end_pos) - start_pos;
-
-      selection_bound = entry->selection_bound;
-      if (selection_bound > start_pos)
-        selection_bound -= MIN (selection_bound, end_pos) - start_pos;
+  g_object_notify (G_OBJECT (entry), "text-length");
+}
 
-      gtk_entry_set_positions (entry, current_pos, selection_bound);
+static void
+buffer_notify_max_length (GtkEntryBuffer *buffer,
+                          GParamSpec     *spec,
+                          GtkEntry       *entry)
+{
+  g_object_notify (G_OBJECT (entry), "max-length");
+}
 
-      /* We might have deleted the selection
-       */
-      gtk_entry_update_primary_selection (entry);
-      
-      gtk_entry_recompute (entry);
+static void
+buffer_connect_signals (GtkEntry *entry)
+{
+  g_signal_connect (get_buffer (entry), "inserted-text", G_CALLBACK (buffer_inserted_text), entry);
+  g_signal_connect (get_buffer (entry), "deleted-text", G_CALLBACK (buffer_deleted_text), entry);
+  g_signal_connect (get_buffer (entry), "notify::text", G_CALLBACK (buffer_notify_text), entry);
+  g_signal_connect (get_buffer (entry), "notify::length", G_CALLBACK (buffer_notify_length), entry);
+  g_signal_connect (get_buffer (entry), "notify::max-length", G_CALLBACK (buffer_notify_max_length), entry);
+}
 
-      emit_changed (entry);
-      g_object_notify (G_OBJECT (editable), "text");
-    }
+static void
+buffer_disconnect_signals (GtkEntry *entry)
+{
+  g_signal_handlers_disconnect_by_func (get_buffer (entry), buffer_inserted_text, entry);
+  g_signal_handlers_disconnect_by_func (get_buffer (entry), buffer_deleted_text, entry);
+  g_signal_handlers_disconnect_by_func (get_buffer (entry), buffer_notify_text, entry);
+  g_signal_handlers_disconnect_by_func (get_buffer (entry), buffer_notify_length, entry);
+  g_signal_handlers_disconnect_by_func (get_buffer (entry), buffer_notify_max_length, entry);
 }
 
 /* Compute the X position for an offset that corresponds to the "more important
@@ -2808,6 +4739,7 @@ static gint
 get_better_cursor_x (GtkEntry *entry,
                     gint      offset)
 {
+  GtkEntryPrivate *priv = entry->priv;
   GdkKeymap *keymap = gdk_keymap_get_for_display (gtk_widget_get_display (GTK_WIDGET (entry)));
   PangoDirection keymap_direction = gdk_keymap_get_direction (keymap);
   gboolean split_cursor;
@@ -2827,7 +4759,7 @@ get_better_cursor_x (GtkEntry *entry,
   if (split_cursor)
     return strong_pos.x / PANGO_SCALE;
   else
-    return (keymap_direction == entry->resolved_dir) ? strong_pos.x / PANGO_SCALE : weak_pos.x / PANGO_SCALE;
+    return (keymap_direction == priv->resolved_dir) ? strong_pos.x / PANGO_SCALE : weak_pos.x / PANGO_SCALE;
 }
 
 static void
@@ -2836,11 +4768,12 @@ gtk_entry_move_cursor (GtkEntry       *entry,
                       gint            count,
                       gboolean        extend_selection)
 {
-  gint new_pos = entry->current_pos;
+  GtkEntryPrivate *priv = entry->priv;
+  gint new_pos = priv->current_pos;
 
   _gtk_entry_reset_im_context (entry);
 
-  if (entry->current_pos != entry->selection_bound && !extend_selection)
+  if (priv->current_pos != priv->selection_bound && !extend_selection)
     {
       /* If we have a current selection and aren't extending it, move to the
        * start/or end of the selection as appropriate
@@ -2849,26 +4782,26 @@ gtk_entry_move_cursor (GtkEntry       *entry,
        {
        case GTK_MOVEMENT_VISUAL_POSITIONS:
          {
-           gint current_x = get_better_cursor_x (entry, entry->current_pos);
-           gint bound_x = get_better_cursor_x (entry, entry->selection_bound);
+           gint current_x = get_better_cursor_x (entry, priv->current_pos);
+           gint bound_x = get_better_cursor_x (entry, priv->selection_bound);
 
            if (count <= 0)
-             new_pos = current_x < bound_x ? entry->current_pos : entry->selection_bound;
+             new_pos = current_x < bound_x ? priv->current_pos : priv->selection_bound;
            else 
-             new_pos = current_x > bound_x ? entry->current_pos : entry->selection_bound;
+             new_pos = current_x > bound_x ? priv->current_pos : priv->selection_bound;
            break;
          }
        case GTK_MOVEMENT_LOGICAL_POSITIONS:
        case GTK_MOVEMENT_WORDS:
          if (count < 0)
-           new_pos = MIN (entry->current_pos, entry->selection_bound);
+           new_pos = MIN (priv->current_pos, priv->selection_bound);
          else
-           new_pos = MAX (entry->current_pos, entry->selection_bound);
+           new_pos = MAX (priv->current_pos, priv->selection_bound);
          break;
        case GTK_MOVEMENT_DISPLAY_LINE_ENDS:
        case GTK_MOVEMENT_PARAGRAPH_ENDS:
        case GTK_MOVEMENT_BUFFER_ENDS:
-         new_pos = count < 0 ? 0 : entry->text_length;
+         new_pos = count < 0 ? 0 : gtk_entry_buffer_get_length (get_buffer (entry));
          break;
        case GTK_MOVEMENT_DISPLAY_LINES:
        case GTK_MOVEMENT_PARAGRAPHS:
@@ -2886,7 +4819,7 @@ gtk_entry_move_cursor (GtkEntry       *entry,
          break;
        case GTK_MOVEMENT_VISUAL_POSITIONS:
          new_pos = gtk_entry_move_visually (entry, new_pos, count);
-          if (entry->current_pos == new_pos)
+          if (priv->current_pos == new_pos)
             {
               if (!extend_selection)
                 {
@@ -2919,14 +4852,14 @@ gtk_entry_move_cursor (GtkEntry       *entry,
              new_pos = gtk_entry_move_backward_word (entry, new_pos, FALSE);
              count++;
            }
-          if (entry->current_pos == new_pos)
+          if (priv->current_pos == new_pos)
             gtk_widget_error_bell (GTK_WIDGET (entry));
          break;
        case GTK_MOVEMENT_DISPLAY_LINE_ENDS:
        case GTK_MOVEMENT_PARAGRAPH_ENDS:
        case GTK_MOVEMENT_BUFFER_ENDS:
-         new_pos = count < 0 ? 0 : entry->text_length;
-          if (entry->current_pos == new_pos)
+         new_pos = count < 0 ? 0 : gtk_entry_buffer_get_length (get_buffer (entry));
+          if (priv->current_pos == new_pos)
             gtk_widget_error_bell (GTK_WIDGET (entry));
          break;
        case GTK_MOVEMENT_DISPLAY_LINES:
@@ -2938,7 +4871,7 @@ gtk_entry_move_cursor (GtkEntry       *entry,
     }
 
   if (extend_selection)
-    gtk_editable_select_region (GTK_EDITABLE (entry), entry->selection_bound, new_pos);
+    gtk_editable_select_region (GTK_EDITABLE (entry), priv->selection_bound, new_pos);
   else
     gtk_editable_set_position (GTK_EDITABLE (entry), new_pos);
   
@@ -2949,10 +4882,11 @@ static void
 gtk_entry_insert_at_cursor (GtkEntry    *entry,
                            const gchar *str)
 {
+  GtkEntryPrivate *priv = entry->priv;
   GtkEditable *editable = GTK_EDITABLE (entry);
-  gint pos = entry->current_pos;
+  gint pos = priv->current_pos;
 
-  if (entry->editable)
+  if (priv->editable)
     {
       _gtk_entry_reset_im_context (entry);
 
@@ -2966,20 +4900,21 @@ gtk_entry_delete_from_cursor (GtkEntry       *entry,
                              GtkDeleteType   type,
                              gint            count)
 {
+  GtkEntryPrivate *priv = entry->priv;
   GtkEditable *editable = GTK_EDITABLE (entry);
-  gint start_pos = entry->current_pos;
-  gint end_pos = entry->current_pos;
-  gint old_n_bytes = entry->n_bytes;
+  gint start_pos = priv->current_pos;
+  gint end_pos = priv->current_pos;
+  gint old_n_bytes = gtk_entry_buffer_get_bytes (get_buffer (entry));
   
   _gtk_entry_reset_im_context (entry);
 
-  if (!entry->editable)
+  if (!priv->editable)
     {
       gtk_widget_error_bell (GTK_WIDGET (entry));
       return;
     }
 
-  if (entry->selection_bound != entry->current_pos)
+  if (priv->selection_bound != priv->current_pos)
     {
       gtk_editable_delete_selection (editable);
       return;
@@ -2988,7 +4923,7 @@ gtk_entry_delete_from_cursor (GtkEntry       *entry,
   switch (type)
     {
     case GTK_DELETE_CHARS:
-      end_pos = gtk_entry_move_logically (entry, entry->current_pos, count);
+      end_pos = gtk_entry_move_logically (entry, priv->current_pos, count);
       gtk_editable_delete_text (editable, MIN (start_pos, end_pos), MAX (start_pos, end_pos));
       break;
     case GTK_DELETE_WORDS:
@@ -3022,9 +4957,9 @@ gtk_entry_delete_from_cursor (GtkEntry       *entry,
     case GTK_DELETE_DISPLAY_LINE_ENDS:
     case GTK_DELETE_PARAGRAPH_ENDS:
       if (count < 0)
-       gtk_editable_delete_text (editable, 0, entry->current_pos);
+       gtk_editable_delete_text (editable, 0, priv->current_pos);
       else
-       gtk_editable_delete_text (editable, entry->current_pos, -1);
+       gtk_editable_delete_text (editable, priv->current_pos, -1);
       break;
     case GTK_DELETE_DISPLAY_LINES:
     case GTK_DELETE_PARAGRAPHS:
@@ -3035,7 +4970,7 @@ gtk_entry_delete_from_cursor (GtkEntry       *entry,
       break;
     }
 
-  if (entry->n_bytes == old_n_bytes)
+  if (gtk_entry_buffer_get_bytes (get_buffer (entry)) == old_n_bytes)
     gtk_widget_error_bell (GTK_WIDGET (entry));
 
   gtk_entry_pend_cursor_blink (entry);
@@ -3044,26 +4979,27 @@ gtk_entry_delete_from_cursor (GtkEntry       *entry,
 static void
 gtk_entry_backspace (GtkEntry *entry)
 {
+  GtkEntryPrivate *priv = entry->priv;
   GtkEditable *editable = GTK_EDITABLE (entry);
   gint prev_pos;
 
   _gtk_entry_reset_im_context (entry);
 
-  if (!entry->editable || !entry->text)
+  if (!priv->editable)
     {
       gtk_widget_error_bell (GTK_WIDGET (entry));
       return;
     }
 
-  if (entry->selection_bound != entry->current_pos)
+  if (priv->selection_bound != priv->current_pos)
     {
       gtk_editable_delete_selection (editable);
       return;
     }
 
-  prev_pos = gtk_entry_move_logically (entry, entry->current_pos, -1);
+  prev_pos = gtk_entry_move_logically (entry, priv->current_pos, -1);
 
-  if (prev_pos < entry->current_pos)
+  if (prev_pos < priv->current_pos)
     {
       PangoLayout *layout = gtk_entry_ensure_layout (entry, FALSE);
       PangoLogAttr *log_attrs;
@@ -3071,25 +5007,24 @@ gtk_entry_backspace (GtkEntry *entry)
 
       pango_layout_get_log_attrs (layout, &log_attrs, &n_attrs);
 
-      if (entry->visible &&
-          log_attrs[entry->current_pos].backspace_deletes_character)
+      /* Deleting parts of characters */
+      if (log_attrs[priv->current_pos].backspace_deletes_character)
        {
          gchar *cluster_text;
          gchar *normalized_text;
           glong  len;
 
-         cluster_text = gtk_editable_get_chars (editable,
-                                                prev_pos,
-                                                entry->current_pos);
+         cluster_text = gtk_entry_get_display_text (entry, prev_pos,
+                                                    priv->current_pos);
          normalized_text = g_utf8_normalize (cluster_text,
                                              strlen (cluster_text),
                                              G_NORMALIZE_NFD);
           len = g_utf8_strlen (normalized_text, -1);
 
-          gtk_editable_delete_text (editable, prev_pos, entry->current_pos);
+          gtk_editable_delete_text (editable, prev_pos, priv->current_pos);
          if (len > 1)
            {
-             gint pos = entry->current_pos;
+             gint pos = priv->current_pos;
 
              gtk_editable_insert_text (editable, normalized_text,
                                        g_utf8_offset_to_pointer (normalized_text, len - 1) - normalized_text,
@@ -3102,7 +5037,7 @@ gtk_entry_backspace (GtkEntry *entry)
        }
       else
        {
-          gtk_editable_delete_text (editable, prev_pos, entry->current_pos);
+          gtk_editable_delete_text (editable, prev_pos, priv->current_pos);
        }
       
       g_free (log_attrs);
@@ -3118,19 +5053,20 @@ gtk_entry_backspace (GtkEntry *entry)
 static void
 gtk_entry_copy_clipboard (GtkEntry *entry)
 {
+  GtkEntryPrivate *priv = entry->priv;
   GtkEditable *editable = GTK_EDITABLE (entry);
   gint start, end;
   gchar *str;
 
   if (gtk_editable_get_selection_bounds (editable, &start, &end))
     {
-      if (!entry->visible)
+      if (!priv->visible)
         {
           gtk_widget_error_bell (GTK_WIDGET (entry));
           return;
         }
 
-      str = gtk_entry_get_public_chars (entry, start, end);
+      str = gtk_entry_get_display_text (entry, start, end);
       gtk_clipboard_set_text (gtk_widget_get_clipboard (GTK_WIDGET (entry),
                                                        GDK_SELECTION_CLIPBOARD),
                              str, -1);
@@ -3141,10 +5077,11 @@ gtk_entry_copy_clipboard (GtkEntry *entry)
 static void
 gtk_entry_cut_clipboard (GtkEntry *entry)
 {
+  GtkEntryPrivate *priv = entry->priv;
   GtkEditable *editable = GTK_EDITABLE (entry);
   gint start, end;
 
-  if (!entry->visible)
+  if (!priv->visible)
     {
       gtk_widget_error_bell (GTK_WIDGET (entry));
       return;
@@ -3152,7 +5089,7 @@ gtk_entry_cut_clipboard (GtkEntry *entry)
 
   gtk_entry_copy_clipboard (entry);
 
-  if (entry->editable)
+  if (priv->editable)
     {
       if (gtk_editable_get_selection_bounds (editable, &start, &end))
        gtk_editable_delete_text (editable, start, end);
@@ -3166,7 +5103,9 @@ gtk_entry_cut_clipboard (GtkEntry *entry)
 static void
 gtk_entry_paste_clipboard (GtkEntry *entry)
 {
-  if (entry->editable)
+  GtkEntryPrivate *priv = entry->priv;
+
+  if (priv->editable)
     gtk_entry_paste (entry, GDK_NONE);
   else
     gtk_widget_error_bell (GTK_WIDGET (entry));
@@ -3175,10 +5114,11 @@ gtk_entry_paste_clipboard (GtkEntry *entry)
 static void
 gtk_entry_delete_cb (GtkEntry *entry)
 {
+  GtkEntryPrivate *priv = entry->priv;
   GtkEditable *editable = GTK_EDITABLE (entry);
   gint start, end;
 
-  if (entry->editable)
+  if (priv->editable)
     {
       if (gtk_editable_get_selection_bounds (editable, &start, &end))
        gtk_editable_delete_text (editable, start, end);
@@ -3188,7 +5128,9 @@ gtk_entry_delete_cb (GtkEntry *entry)
 static void
 gtk_entry_toggle_overwrite (GtkEntry *entry)
 {
-  entry->overwrite_mode = !entry->overwrite_mode;
+  GtkEntryPrivate *priv = entry->priv;
+
+  priv->overwrite_mode = !priv->overwrite_mode;
   gtk_entry_pend_cursor_blink (entry);
   gtk_widget_queue_draw (GTK_WIDGET (entry));
 }
@@ -3202,24 +5144,29 @@ gtk_entry_select_all (GtkEntry *entry)
 static void
 gtk_entry_real_activate (GtkEntry *entry)
 {
+  GtkEntryPrivate *priv = entry->priv;
   GtkWindow *window;
+  GtkWidget *default_widget, *focus_widget;
   GtkWidget *toplevel;
   GtkWidget *widget;
 
   widget = GTK_WIDGET (entry);
 
-  if (entry->activates_default)
+  if (priv->activates_default)
     {
       toplevel = gtk_widget_get_toplevel (widget);
       if (GTK_IS_WINDOW (toplevel))
        {
          window = GTK_WINDOW (toplevel);
-      
-         if (window &&
-             widget != window->default_widget &&
-             !(widget == window->focus_widget &&
-               (!window->default_widget || !GTK_WIDGET_SENSITIVE (window->default_widget))))
-           gtk_window_activate_default (window);
+
+         if (window)
+            {
+              default_widget = gtk_window_get_default_widget (window);
+              focus_widget = gtk_window_get_focus (window);
+              if (widget != default_widget &&
+                  !(widget == focus_widget && (!default_widget || !gtk_widget_get_sensitive (default_widget))))
+               gtk_window_activate_default (window);
+            }
        }
     }
 }
@@ -3239,7 +5186,9 @@ gtk_entry_commit_cb (GtkIMContext *context,
                     const gchar  *str,
                     GtkEntry     *entry)
 {
-  if (entry->editable)
+  GtkEntryPrivate *priv = entry->priv;
+
+  if (priv->editable)
     gtk_entry_enter_text (entry, str);
 }
 
@@ -3247,17 +5196,20 @@ static void
 gtk_entry_preedit_changed_cb (GtkIMContext *context,
                              GtkEntry     *entry)
 {
-  if (entry->editable)
+  GtkEntryPrivate *priv = entry->priv;
+
+  if (priv->editable)
     {
       gchar *preedit_string;
       gint cursor_pos;
-      
-      gtk_im_context_get_preedit_string (entry->im_context,
+
+      gtk_im_context_get_preedit_string (priv->im_context,
                                          &preedit_string, NULL,
                                          &cursor_pos);
-      entry->preedit_length = strlen (preedit_string);
+      g_signal_emit (entry, signals[PREEDIT_CHANGED], 0, preedit_string);
+      priv->preedit_length = strlen (preedit_string);
       cursor_pos = CLAMP (cursor_pos, 0, g_utf8_strlen (preedit_string, -1));
-      entry->preedit_cursor = cursor_pos;
+      priv->preedit_cursor = cursor_pos;
       g_free (preedit_string);
     
       gtk_entry_recompute (entry);
@@ -3266,12 +5218,16 @@ gtk_entry_preedit_changed_cb (GtkIMContext *context,
 
 static gboolean
 gtk_entry_retrieve_surrounding_cb (GtkIMContext *context,
-                              GtkEntry     *entry)
+                                   GtkEntry     *entry)
 {
-  gtk_im_context_set_surrounding (context,
-                                 entry->text,
-                                 entry->n_bytes,
-                                 g_utf8_offset_to_pointer (entry->text, entry->current_pos) - entry->text);
+  GtkEntryPrivate *priv = entry->priv;
+  gchar *text;
+
+  /* XXXX ??? does this even make sense when text is not visible? Should we return FALSE? */
+  text = gtk_entry_get_display_text (entry, 0, -1);
+  gtk_im_context_set_surrounding (context, text, strlen (text), /* Length in bytes */
+                                 g_utf8_offset_to_pointer (text, priv->current_pos) - text);
+  g_free (text);
 
   return TRUE;
 }
@@ -3282,10 +5238,12 @@ gtk_entry_delete_surrounding_cb (GtkIMContext *slave,
                                 gint          n_chars,
                                 GtkEntry     *entry)
 {
-  if (entry->editable)
+  GtkEntryPrivate *priv = entry->priv;
+
+  if (priv->editable)
     gtk_editable_delete_text (GTK_EDITABLE (entry),
-                              entry->current_pos + offset,
-                              entry->current_pos + offset + n_chars);
+                              priv->current_pos + offset,
+                              priv->current_pos + offset + n_chars);
 
   return TRUE;
 }
@@ -3298,29 +5256,30 @@ static void
 gtk_entry_enter_text (GtkEntry       *entry,
                       const gchar    *str)
 {
+  GtkEntryPrivate *priv = entry->priv;
   GtkEditable *editable = GTK_EDITABLE (entry);
   gint tmp_pos;
   gboolean old_need_im_reset;
 
-  old_need_im_reset = entry->need_im_reset;
-  entry->need_im_reset = FALSE;
+  old_need_im_reset = priv->need_im_reset;
+  priv->need_im_reset = FALSE;
 
   if (gtk_editable_get_selection_bounds (editable, NULL, NULL))
     gtk_editable_delete_selection (editable);
   else
     {
-      if (entry->overwrite_mode)
+      if (priv->overwrite_mode)
         gtk_entry_delete_from_cursor (entry, GTK_DELETE_CHARS, 1);
     }
 
-  tmp_pos = entry->current_pos;
+  tmp_pos = priv->current_pos;
   gtk_editable_insert_text (editable, str, strlen (str), &tmp_pos);
   gtk_editable_set_position (editable, tmp_pos);
 
-  entry->need_im_reset = old_need_im_reset;
+  priv->need_im_reset = old_need_im_reset;
 }
 
-/* All changes to entry->current_pos and entry->selection_bound
+/* All changes to priv->current_pos and priv->selection_bound
  * should go through this function.
  */
 static void
@@ -3328,23 +5287,24 @@ gtk_entry_set_positions (GtkEntry *entry,
                         gint      current_pos,
                         gint      selection_bound)
 {
+  GtkEntryPrivate *priv = entry->priv;
   gboolean changed = FALSE;
 
   g_object_freeze_notify (G_OBJECT (entry));
   
   if (current_pos != -1 &&
-      entry->current_pos != current_pos)
+      priv->current_pos != current_pos)
     {
-      entry->current_pos = current_pos;
+      priv->current_pos = current_pos;
       changed = TRUE;
 
       g_object_notify (G_OBJECT (entry), "cursor-position");
     }
 
   if (selection_bound != -1 &&
-      entry->selection_bound != selection_bound)
+      priv->selection_bound != selection_bound)
     {
-      entry->selection_bound = selection_bound;
+      priv->selection_bound = selection_bound;
       changed = TRUE;
       
       g_object_notify (G_OBJECT (entry), "selection-bound");
@@ -3362,26 +5322,28 @@ gtk_entry_set_positions (GtkEntry *entry,
 static void
 gtk_entry_reset_layout (GtkEntry *entry)
 {
-  if (entry->cached_layout)
+  GtkEntryPrivate *priv = entry->priv;
+
+  if (priv->cached_layout)
     {
-      g_object_unref (entry->cached_layout);
-      entry->cached_layout = NULL;
+      g_object_unref (priv->cached_layout);
+      priv->cached_layout = NULL;
     }
 }
 
 static void
 update_im_cursor_location (GtkEntry *entry)
 {
+  GtkEntryPrivate *priv = entry->priv;
   GdkRectangle area;
   gint strong_x;
   gint strong_xoffset;
   gint area_width, area_height;
 
-  gtk_entry_get_cursor_locations (entry, CURSOR_STANDARD, &strong_x, NULL)
-;
-  get_text_area_size (entry, NULL, NULL, &area_width, &area_height);
+  gtk_entry_get_cursor_locations (entry, CURSOR_STANDARD, &strong_x, NULL);
+  gtk_entry_get_text_area_size (entry, NULL, NULL, &area_width, &area_height);
 
-  strong_xoffset = strong_x - entry->scroll_offset;
+  strong_xoffset = strong_x - priv->scroll_offset;
   if (strong_xoffset < 0)
     {
       strong_xoffset = 0;
@@ -3395,23 +5357,22 @@ update_im_cursor_location (GtkEntry *entry)
   area.width = 0;
   area.height = area_height;
 
-  gtk_im_context_set_cursor_location (entry->im_context, &area);
+  gtk_im_context_set_cursor_location (priv->im_context, &area);
 }
 
 static gboolean
 recompute_idle_func (gpointer data)
 {
-  GtkEntry *entry;
+  GtkEntry *entry = GTK_ENTRY (data);
+  GtkEntryPrivate *priv = entry->priv;
 
-  entry = GTK_ENTRY (data);
+  priv->recompute_idle = 0;
 
-  entry->recompute_idle = 0;
-  
   if (gtk_widget_has_screen (GTK_WIDGET (entry)))
     {
       gtk_entry_adjust_scroll (entry);
-      gtk_entry_queue_draw (entry);
-      
+      gtk_widget_queue_draw (GTK_WIDGET (entry));
+
       update_im_cursor_location (entry);
     }
 
@@ -3421,93 +5382,52 @@ recompute_idle_func (gpointer data)
 static void
 gtk_entry_recompute (GtkEntry *entry)
 {
+  GtkEntryPrivate *priv = entry->priv;
+
   gtk_entry_reset_layout (entry);
   gtk_entry_check_cursor_blink (entry);
-  
-  if (!entry->recompute_idle)
-    {
-      entry->recompute_idle = gdk_threads_add_idle_full (G_PRIORITY_HIGH_IDLE + 15, /* between resize and redraw */
-                                              recompute_idle_func, entry, NULL); 
-    }
-}
 
-static void
-append_char (GString *str,
-             gunichar ch,
-             gint     count)
-{
-  gint i;
-  gint char_len;
-  gchar buf[7];
-  
-  char_len = g_unichar_to_utf8 (ch, buf);
-  
-  i = 0;
-  while (i < count)
+  if (!priv->recompute_idle)
     {
-      g_string_append_len (str, buf, char_len);
-      ++i;
+      priv->recompute_idle = gdk_threads_add_idle_full (G_PRIORITY_HIGH_IDLE + 15, /* between resize and redraw */
+                                              recompute_idle_func, entry, NULL); 
     }
 }
 
-static gboolean
-gtk_entry_remove_password_hint (gpointer data)
-{
-  /* Force the string to be redrawn, but now without a visible character */
-  gtk_entry_recompute (GTK_ENTRY (data));
-
-  return FALSE;
-}
-
 static PangoLayout *
 gtk_entry_create_layout (GtkEntry *entry,
                         gboolean  include_preedit)
 {
+  GtkEntryPrivate *priv = entry->priv;
   GtkWidget *widget = GTK_WIDGET (entry);
   PangoLayout *layout = gtk_widget_create_pango_layout (widget, NULL);
   PangoAttrList *tmp_attrs = pango_attr_list_new ();
-  
+
   gchar *preedit_string = NULL;
   gint preedit_length = 0;
   PangoAttrList *preedit_attrs = NULL;
 
+  gchar *display;
+  guint n_bytes;
+
   pango_layout_set_single_paragraph_mode (layout, TRUE);
 
+  display = gtk_entry_get_display_text (entry, 0, -1);
+  n_bytes = strlen (display);
+
   if (include_preedit)
     {
-      gtk_im_context_get_preedit_string (entry->im_context,
+      gtk_im_context_get_preedit_string (priv->im_context,
                                         &preedit_string, &preedit_attrs, NULL);
-      preedit_length = entry->preedit_length;
+      preedit_length = priv->preedit_length;
     }
 
   if (preedit_length)
     {
-      GString *tmp_string = g_string_new (NULL);
-      
-      gint cursor_index = g_utf8_offset_to_pointer (entry->text, entry->current_pos) - entry->text;
-      
-      if (entry->visible)
-        {
-          g_string_prepend_len (tmp_string, entry->text, entry->n_bytes);
-          g_string_insert (tmp_string, cursor_index, preedit_string);
-        }
-      else
-        {
-          gint ch_len;
-          gunichar invisible_char;
+      GString *tmp_string = g_string_new (display);
+      gint cursor_index = g_utf8_offset_to_pointer (display, priv->current_pos) - display;
 
-          if (entry->invisible_char != 0)
-            invisible_char = entry->invisible_char;
-          else
-            invisible_char = ' '; /* just pick a char */
-
-          ch_len = g_utf8_strlen (entry->text, entry->n_bytes);
-          append_char (tmp_string, invisible_char, ch_len);
-          cursor_index =
-            g_utf8_offset_to_pointer (tmp_string->str, entry->current_pos) -
-            tmp_string->str;
-          g_string_insert (tmp_string, cursor_index, preedit_string);
-        }
+      g_string_insert (tmp_string, cursor_index, preedit_string);
       
       pango_layout_set_text (layout, tmp_string->str, tmp_string->len);
       
@@ -3520,15 +5440,14 @@ gtk_entry_create_layout (GtkEntry *entry,
     {
       PangoDirection pango_dir;
       
-      if (entry->visible)
-       pango_dir = pango_find_base_dir (entry->text, entry->n_bytes);
-
+      if (gtk_entry_get_display_mode (entry) == DISPLAY_NORMAL)
+       pango_dir = pango_find_base_dir (display, n_bytes);
       else
        pango_dir = PANGO_DIRECTION_NEUTRAL;
 
       if (pango_dir == PANGO_DIRECTION_NEUTRAL)
         {
-          if (GTK_WIDGET_HAS_FOCUS (widget))
+          if (gtk_widget_has_focus (widget))
            {
              GdkDisplay *display = gtk_widget_get_display (widget);
              GdkKeymap *keymap = gdk_keymap_get_for_display (display);
@@ -3549,79 +5468,16 @@ gtk_entry_create_layout (GtkEntry *entry,
       pango_context_set_base_dir (gtk_widget_get_pango_context (widget),
                                  pango_dir);
 
-      entry->resolved_dir = pango_dir;
-      
-      if (entry->visible)
-        {
-          pango_layout_set_text (layout, entry->text, entry->n_bytes);
-        }
-      else
-        {
-          GString *str = g_string_new (NULL);
-          gunichar invisible_char;
-          guint password_hint_timeout;
-          GtkEntryPasswordHint *password_hint;
-
-          g_object_get (gtk_widget_get_settings (widget),
-                        "gtk-entry-password-hint-timeout", &password_hint_timeout,
-                        NULL);
-
-          if (entry->invisible_char != 0)
-            invisible_char = entry->invisible_char;
-          else
-            invisible_char = ' '; /* just pick a char */
-
-          password_hint = g_object_get_qdata (G_OBJECT (entry),
-                                              quark_password_hint);
-
-          if (password_hint && password_hint->password_hint_timeout_id)
-            {
-              g_source_remove (password_hint->password_hint_timeout_id);
-              password_hint->password_hint_timeout_id = 0;
-            }
-
-          if (password_hint_timeout == 0 || password_hint == NULL ||
-              (password_hint && password_hint->password_hint_length == 0))
-            {
-              append_char (str, invisible_char, entry->text_length);
-            }
-          else if (password_hint)
-            {
-              /* Draw hidden characters upto the inserted position,
-               * then the real thing, pad up to full length
-               */
-              if (password_hint->password_hint_position > 1)
-                append_char (str, invisible_char,
-                             password_hint->password_hint_position - 1);
-
-              g_string_append_len (str, password_hint->password_hint,
-                                   password_hint->password_hint_length);
-
-              if (password_hint->password_hint_position < entry->text_length)
-                append_char (str, invisible_char,
-                             entry->text_length -
-                             password_hint->password_hint_position);
-
-              /* Now remove this last input character, don't need
-               * it anymore
-               */
-              memset (password_hint->password_hint, 0, PASSWORD_HINT_MAX);
-              password_hint->password_hint_length = 0;
-
-              password_hint->password_hint_timeout_id =
-                gdk_threads_add_timeout (password_hint_timeout,
-                               (GSourceFunc) gtk_entry_remove_password_hint,
-                               entry);
-            }
+      priv->resolved_dir = pango_dir;
 
-          pango_layout_set_text (layout, str->str, str->len);
-          g_string_free (str, TRUE);
-        }
+      pango_layout_set_text (layout, display, n_bytes);
     }
       
   pango_layout_set_attributes (layout, tmp_attrs);
 
   g_free (preedit_string);
+  g_free (display);
+
   if (preedit_attrs)
     pango_attr_list_unref (preedit_attrs);
       
@@ -3634,17 +5490,19 @@ static PangoLayout *
 gtk_entry_ensure_layout (GtkEntry *entry,
                          gboolean  include_preedit)
 {
-  if (entry->preedit_length > 0 &&
-      !include_preedit != !entry->cache_includes_preedit)
+  GtkEntryPrivate *priv = entry->priv;
+
+  if (priv->preedit_length > 0 &&
+      !include_preedit != !priv->cache_includes_preedit)
     gtk_entry_reset_layout (entry);
 
-  if (!entry->cached_layout)
+  if (!priv->cached_layout)
     {
-      entry->cached_layout = gtk_entry_create_layout (entry, include_preedit);
-      entry->cache_includes_preedit = include_preedit;
+      priv->cached_layout = gtk_entry_create_layout (entry, include_preedit);
+      priv->cache_includes_preedit = include_preedit;
     }
-  
-  return entry->cached_layout;
+
+  return priv->cached_layout;
 }
 
 static void
@@ -3652,6 +5510,7 @@ get_layout_position (GtkEntry *entry,
                      gint     *x,
                      gint     *y)
 {
+  GtkEntryPrivate *priv = entry->priv;
   PangoLayout *layout;
   PangoRectangle logical_rect;
   gint area_width, area_height;
@@ -3661,7 +5520,7 @@ get_layout_position (GtkEntry *entry,
   
   layout = gtk_entry_ensure_layout (entry, TRUE);
 
-  get_text_area_size (entry, NULL, NULL, &area_width, &area_height);
+  gtk_entry_get_text_area_size (entry, NULL, NULL, &area_width, &area_height);
   _gtk_entry_effective_inner_border (entry, &inner_border);
 
   area_height = PANGO_SCALE * (area_height - inner_border.top - inner_border.bottom);
@@ -3670,9 +5529,9 @@ get_layout_position (GtkEntry *entry,
   pango_layout_line_get_extents (line, NULL, &logical_rect);
   
   /* Align primarily for locale's ascent/descent */
-  y_pos = ((area_height - entry->ascent - entry->descent) / 2 + 
-           entry->ascent + logical_rect.y);
-  
+  y_pos = ((area_height - priv->ascent - priv->descent) / 2 +
+           priv->ascent + logical_rect.y);
+
   /* Now see if we need to adjust to fit in actual drawn string */
   if (logical_rect.height > area_height)
     y_pos = (area_height - logical_rect.height) / 2;
@@ -3684,86 +5543,162 @@ get_layout_position (GtkEntry *entry,
   y_pos = inner_border.top + y_pos / PANGO_SCALE;
 
   if (x)
-    *x = inner_border.left - entry->scroll_offset;
+    *x = inner_border.left - priv->scroll_offset;
 
   if (y)
     *y = y_pos;
 }
 
 static void
-gtk_entry_draw_text (GtkEntry *entry)
+draw_text_with_color (GtkEntry *entry,
+                      cairo_t  *cr,
+                      GdkRGBA  *default_color)
 {
+  GtkEntryPrivate *priv = entry->priv;
+  PangoLayout *layout = gtk_entry_ensure_layout (entry, TRUE);
   GtkWidget *widget;
-  
-  if (!entry->visible && entry->invisible_char == 0)
-    return;
-  
-  if (GTK_WIDGET_DRAWABLE (entry))
+  gint x, y;
+  gint start_pos, end_pos;
+
+  widget = GTK_WIDGET (entry);
+
+  cairo_save (cr);
+
+  get_layout_position (entry, &x, &y);
+
+  cairo_move_to (cr, x, y);
+  gdk_cairo_set_source_rgba (cr, default_color);
+  pango_cairo_show_layout (cr, layout);
+
+  if (gtk_editable_get_selection_bounds (GTK_EDITABLE (entry), &start_pos, &end_pos))
     {
-      PangoLayout *layout = gtk_entry_ensure_layout (entry, TRUE);
-      cairo_t *cr;
-      gint x, y;
-      gint start_pos, end_pos;
-      
-      widget = GTK_WIDGET (entry);
-      
-      get_layout_position (entry, &x, &y);
+      gint *ranges;
+      gint n_ranges, i;
+      PangoRectangle logical_rect;
+      GdkRGBA selection_color, text_color;
+      GtkBorder inner_border;
+      GtkStyleContext *context;
+      GtkStateFlags state;
+
+      context = gtk_widget_get_style_context (widget);
+      pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
+      gtk_entry_get_pixel_ranges (entry, &ranges, &n_ranges);
+
+      state = GTK_STATE_FLAG_SELECTED;
 
-      cr = gdk_cairo_create (entry->text_area);
+      if (gtk_widget_has_focus (widget))
+        state |= GTK_STATE_FLAG_FOCUSED;
+
+      gtk_style_context_get_background_color (context, state, &selection_color);
+      gtk_style_context_get_color (context, state, &text_color);
+
+      _gtk_entry_effective_inner_border (entry, &inner_border);
+
+      for (i = 0; i < n_ranges; ++i)
+        cairo_rectangle (cr,
+                         inner_border.left - priv->scroll_offset + ranges[2 * i],
+                        y,
+                        ranges[2 * i + 1],
+                        logical_rect.height);
+
+      cairo_clip (cr);
+         
+      gdk_cairo_set_source_rgba (cr, &selection_color);
+      cairo_paint (cr);
 
       cairo_move_to (cr, x, y);
-      gdk_cairo_set_source_color (cr, &widget->style->text [widget->state]);
+      gdk_cairo_set_source_rgba (cr, &text_color);
       pango_cairo_show_layout (cr, layout);
+  
+      g_free (ranges);
+    }
+  cairo_restore (cr);
+}
 
-      if (gtk_editable_get_selection_bounds (GTK_EDITABLE (entry), &start_pos, &end_pos))
-       {
-         gint *ranges;
-         gint n_ranges, i;
-          PangoRectangle logical_rect;
-         GdkColor *selection_color, *text_color;
-          GtkBorder inner_border;
+static void
+gtk_entry_draw_text (GtkEntry *entry,
+                     cairo_t  *cr)
+{
+  GtkEntryPrivate *priv = entry->priv;
+  GtkWidget *widget = GTK_WIDGET (entry);
+  GtkStateFlags state = 0;
+  GdkRGBA text_color, bar_text_color;
+  GtkStyleContext *context;
+  gint pos_x, pos_y;
+  gint width, height;
+  gint progress_x, progress_y, progress_width, progress_height;
+  gint clip_width, clip_height;
+
+  /* Nothing to display at all */
+  if (gtk_entry_get_display_mode (entry) == DISPLAY_BLANK)
+    return;
 
-         pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
-         gtk_entry_get_pixel_ranges (entry, &ranges, &n_ranges);
+  state = gtk_widget_get_state_flags (widget);
+  context = gtk_widget_get_style_context (widget);
 
-         if (GTK_WIDGET_HAS_FOCUS (entry))
-           {
-             selection_color = &widget->style->base [GTK_STATE_SELECTED];
-             text_color = &widget->style->text [GTK_STATE_SELECTED];
-           }
-         else
-           {
-             selection_color = &widget->style->base [GTK_STATE_ACTIVE];
-             text_color = &widget->style->text [GTK_STATE_ACTIVE];
-           }
+  gtk_style_context_get_color (context, state, &text_color);
 
-          _gtk_entry_effective_inner_border (entry, &inner_border);
+  /* Get foreground color for progressbars */
+  gtk_style_context_save (context);
+  gtk_style_context_add_class (context, GTK_STYLE_CLASS_PROGRESSBAR);
+  gtk_style_context_get_color (context, state, &bar_text_color);
+  gtk_style_context_restore (context);
 
-         for (i = 0; i < n_ranges; ++i)
-           cairo_rectangle (cr,
-                            inner_border.left - entry->scroll_offset + ranges[2 * i],
-                            y,
-                            ranges[2 * i + 1],
-                            logical_rect.height);
+  get_progress_area (widget,
+                     &progress_x, &progress_y,
+                     &progress_width, &progress_height);
 
-         cairo_clip (cr);
-         
-         gdk_cairo_set_source_color (cr, selection_color);
-         cairo_paint (cr);
+  clip_width = gdk_window_get_width (priv->text_area);
+  clip_height = gdk_window_get_height (priv->text_area);
+  cairo_rectangle (cr, 0, 0, clip_width, clip_height);
+  cairo_clip (cr);
 
-         cairo_move_to (cr, x, y);
-         gdk_cairo_set_source_color (cr, text_color);
-         pango_cairo_show_layout (cr, layout);
-         
-         g_free (ranges);
-       }
+  /* If the color is the same, or the progress area has a zero
+   * size, then we only need to draw once. */
+  if (gdk_rgba_equal (&text_color, &bar_text_color) ||
+      ((progress_width == 0) || (progress_height == 0)))
+    {
+      draw_text_with_color (entry, cr, &text_color);
+    }
+  else
+    {
+      width = gdk_window_get_width (priv->text_area);
+      height = gdk_window_get_height (priv->text_area);
+
+      cairo_save (cr);
+
+      cairo_rectangle (cr, 0, 0, width, height);
+      cairo_clip (cr);
+      cairo_save (cr);
+
+      cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
+      cairo_rectangle (cr, 0, 0, width, height);
+
+      gdk_window_get_position (priv->text_area, &pos_x, &pos_y);
+      progress_x -= pos_x;
+      progress_y -= pos_y;
+
+      cairo_rectangle (cr, progress_x, progress_y,
+                       progress_width, progress_height);
+      cairo_clip (cr);
+      cairo_set_fill_rule (cr, CAIRO_FILL_RULE_WINDING);
+  
+      draw_text_with_color (entry, cr, &text_color);
+      cairo_restore (cr);
 
-      cairo_destroy (cr);
+      cairo_rectangle (cr, progress_x, progress_y,
+                       progress_width, progress_height);
+      cairo_clip (cr);
+
+      draw_text_with_color (entry, cr, &bar_text_color);
+
+      cairo_restore (cr);
     }
 }
 
 static void
 draw_insertion_cursor (GtkEntry      *entry,
+                       cairo_t       *cr,
                       GdkRectangle  *cursor_location,
                       gboolean       is_primary,
                       PangoDirection direction,
@@ -3777,155 +5712,215 @@ draw_insertion_cursor (GtkEntry      *entry,
   else
     text_dir = GTK_TEXT_DIR_RTL;
 
-  gtk_draw_insertion_cursor (widget, entry->text_area, NULL,
+  gtk_draw_insertion_cursor (widget, cr,
                             cursor_location,
                             is_primary, text_dir, draw_arrow);
 }
 
 static void
 gtk_entry_draw_cursor (GtkEntry  *entry,
+                       cairo_t   *cr,
                       CursorType type)
 {
+  GtkEntryPrivate *priv = entry->priv;
+  GtkWidget *widget = GTK_WIDGET (entry);
   GdkKeymap *keymap = gdk_keymap_get_for_display (gtk_widget_get_display (GTK_WIDGET (entry)));
   PangoDirection keymap_direction = gdk_keymap_get_direction (keymap);
-  
-  if (GTK_WIDGET_DRAWABLE (entry))
-    {
-      GtkWidget *widget = GTK_WIDGET (entry);
-      GdkRectangle cursor_location;
-      gboolean split_cursor;
-      PangoRectangle cursor_rect;
-      GtkBorder inner_border;
-      gint xoffset;
-      gint text_area_height;
-      gint cursor_index;
-      gboolean block;
-      gboolean block_at_line_end;
-      PangoLayout *layout;
-      const char *text;
-
-      _gtk_entry_effective_inner_border (entry, &inner_border);
-
-      xoffset = inner_border.left - entry->scroll_offset;
+  GdkRectangle cursor_location;
+  gboolean split_cursor;
+  PangoRectangle cursor_rect;
+  GtkBorder inner_border;
+  gint xoffset;
+  gint text_area_height;
+  gint cursor_index;
+  gboolean block;
+  gboolean block_at_line_end;
+  PangoLayout *layout;
+  const char *text;
 
-      gdk_drawable_get_size (entry->text_area, NULL, &text_area_height);
+  _gtk_entry_effective_inner_border (entry, &inner_border);
 
-      layout = gtk_entry_ensure_layout (entry, TRUE);
-      text = pango_layout_get_text (layout);
-      cursor_index = g_utf8_offset_to_pointer (text, entry->current_pos + entry->preedit_cursor) - text;
-      if (!entry->overwrite_mode)
-        block = FALSE;
-      else
-        block = _gtk_text_util_get_block_cursor_location (layout,
-                                                          cursor_index, &cursor_rect, &block_at_line_end);
+  xoffset = inner_border.left - priv->scroll_offset;
 
-      if (!block)
-        {
-          gint strong_x, weak_x;
-          PangoDirection dir1 = PANGO_DIRECTION_NEUTRAL;
-          PangoDirection dir2 = PANGO_DIRECTION_NEUTRAL;
-          gint x1 = 0;
-          gint x2 = 0;
+  text_area_height = gdk_window_get_height (priv->text_area);
 
-          gtk_entry_get_cursor_locations (entry, type, &strong_x, &weak_x);
+  layout = gtk_entry_ensure_layout (entry, TRUE);
+  text = pango_layout_get_text (layout);
+  cursor_index = g_utf8_offset_to_pointer (text, priv->current_pos + priv->preedit_cursor) - text;
+  if (!priv->overwrite_mode)
+    block = FALSE;
+  else
+    block = _gtk_text_util_get_block_cursor_location (layout,
+                                                      cursor_index, &cursor_rect, &block_at_line_end);
 
-          g_object_get (gtk_widget_get_settings (widget),
-                        "gtk-split-cursor", &split_cursor,
-                        NULL);
+  if (!block)
+    {
+      gint strong_x, weak_x;
+      PangoDirection dir1 = PANGO_DIRECTION_NEUTRAL;
+      PangoDirection dir2 = PANGO_DIRECTION_NEUTRAL;
+      gint x1 = 0;
+      gint x2 = 0;
 
-          dir1 = entry->resolved_dir;
-      
-          if (split_cursor)
-            {
-              x1 = strong_x;
+      gtk_entry_get_cursor_locations (entry, type, &strong_x, &weak_x);
 
-              if (weak_x != strong_x)
-                {
-                  dir2 = (entry->resolved_dir == PANGO_DIRECTION_LTR) ? PANGO_DIRECTION_RTL : PANGO_DIRECTION_LTR;
-                  x2 = weak_x;
-                }
-            }
-          else
-            {
-              if (keymap_direction == entry->resolved_dir)
-                x1 = strong_x;
-              else
-                x1 = weak_x;
-            }
+      g_object_get (gtk_widget_get_settings (widget),
+                    "gtk-split-cursor", &split_cursor,
+                    NULL);
 
-          cursor_location.x = xoffset + x1;
-          cursor_location.y = inner_border.top;
-          cursor_location.width = 0;
-          cursor_location.height = text_area_height - inner_border.top - inner_border.bottom;
+      dir1 = priv->resolved_dir;
+  
+      if (split_cursor)
+        {
+          x1 = strong_x;
 
-          draw_insertion_cursor (entry,
-                                 &cursor_location, TRUE, dir1,
-                                 dir2 != PANGO_DIRECTION_NEUTRAL);
-      
-          if (dir2 != PANGO_DIRECTION_NEUTRAL)
+          if (weak_x != strong_x)
             {
-              cursor_location.x = xoffset + x2;
-              draw_insertion_cursor (entry,
-                                     &cursor_location, FALSE, dir2,
-                                     TRUE);
+              dir2 = (priv->resolved_dir == PANGO_DIRECTION_LTR) ? PANGO_DIRECTION_RTL : PANGO_DIRECTION_LTR;
+              x2 = weak_x;
             }
         }
-      else /* overwrite_mode */
+      else
+        {
+          if (keymap_direction == priv->resolved_dir)
+            x1 = strong_x;
+          else
+            x1 = weak_x;
+        }
+
+      cursor_location.x = xoffset + x1;
+      cursor_location.y = inner_border.top;
+      cursor_location.width = 0;
+      cursor_location.height = text_area_height - inner_border.top - inner_border.bottom;
+
+      draw_insertion_cursor (entry, cr,
+                             &cursor_location, TRUE, dir1,
+                             dir2 != PANGO_DIRECTION_NEUTRAL);
+  
+      if (dir2 != PANGO_DIRECTION_NEUTRAL)
         {
-          GdkColor cursor_color;
-          GdkRectangle rect;
-          cairo_t *cr;
-          gint x, y;
+          cursor_location.x = xoffset + x2;
+          draw_insertion_cursor (entry, cr,
+                                 &cursor_location, FALSE, dir2,
+                                 TRUE);
+        }
+    }
+  else /* overwrite_mode */
+    {
+      GtkStyleContext *context;
+      GdkRGBA cursor_color;
+      GdkRectangle rect;
+      gint x, y;
 
-          get_layout_position (entry, &x, &y);
+      cairo_save (cr);
 
-          rect.x = PANGO_PIXELS (cursor_rect.x) + x;
-          rect.y = PANGO_PIXELS (cursor_rect.y) + y;
-          rect.width = PANGO_PIXELS (cursor_rect.width);
-          rect.height = PANGO_PIXELS (cursor_rect.height);
+      get_layout_position (entry, &x, &y);
 
-          cr = gdk_cairo_create (entry->text_area);
+      rect.x = PANGO_PIXELS (cursor_rect.x) + x;
+      rect.y = PANGO_PIXELS (cursor_rect.y) + y;
+      rect.width = PANGO_PIXELS (cursor_rect.width);
+      rect.height = PANGO_PIXELS (cursor_rect.height);
 
-          _gtk_widget_get_cursor_color (widget, &cursor_color);
-          gdk_cairo_set_source_color (cr, &cursor_color);
-          gdk_cairo_rectangle (cr, &rect);
-          cairo_fill (cr);
+      context = gtk_widget_get_style_context (widget);
 
-          if (!block_at_line_end)
-            {
-              gdk_cairo_rectangle (cr, &rect);
-              cairo_clip (cr);
-              cairo_move_to (cr, x, y);
-              gdk_cairo_set_source_color (cr, &widget->style->base[widget->state]);
-              pango_cairo_show_layout (cr, layout);
-            }
+      _gtk_style_context_get_cursor_color (context, &cursor_color, NULL);
+      gdk_cairo_set_source_rgba (cr, &cursor_color);
+      gdk_cairo_rectangle (cr, &rect);
+      cairo_fill (cr);
 
-          cairo_destroy (cr);
+      if (!block_at_line_end)
+        {
+          GtkStateFlags state;
+          GdkRGBA color;
+
+          state = gtk_widget_get_state_flags (widget);
+          gtk_style_context_get_background_color (context, state, &color);
+
+          gdk_cairo_rectangle (cr, &rect);
+          cairo_clip (cr);
+          cairo_move_to (cr, x, y);
+          gdk_cairo_set_source_rgba (cr, &color);
+          pango_cairo_show_layout (cr, layout);
         }
-    }
-}
 
-static void
-gtk_entry_queue_draw (GtkEntry *entry)
-{
-  if (GTK_WIDGET_DRAWABLE (entry))
-    gdk_window_invalidate_rect (entry->text_area, NULL, FALSE);
+      cairo_restore (cr);
+    }
 }
 
 void
 _gtk_entry_reset_im_context (GtkEntry *entry)
 {
-  if (entry->need_im_reset)
+  GtkEntryPrivate *priv = entry->priv;
+
+  if (priv->need_im_reset)
     {
-      entry->need_im_reset = FALSE;
-      gtk_im_context_reset (entry->im_context);
+      priv->need_im_reset = FALSE;
+      gtk_im_context_reset (priv->im_context);
     }
 }
 
+/**
+ * gtk_entry_reset_im_context:
+ * @entry: a #GtkEntry
+ *
+ * Reset the input method context of the entry if needed.
+ *
+ * This can be necessary in the case where modifying the buffer
+ * would confuse on-going input method behavior.
+ *
+ * Since: 2.22
+ */
+void
+gtk_entry_reset_im_context (GtkEntry *entry)
+{
+  g_return_if_fail (GTK_IS_ENTRY (entry));
+
+  _gtk_entry_reset_im_context (entry);
+}
+
+/**
+ * gtk_entry_im_context_filter_keypress:
+ * @entry: a #GtkEntry
+ * @event: the key event
+ *
+ * Allow the #GtkEntry input method to internally handle key press
+ * and release events. If this function returns %TRUE, then no further
+ * processing should be done for this key event. See
+ * gtk_im_context_filter_keypress().
+ *
+ * Note that you are expected to call this function from your handler
+ * when overriding key event handling. This is needed in the case when
+ * you need to insert your own key handling between the input method
+ * and the default key event handling of the #GtkEntry.
+ * See gtk_text_view_reset_im_context() for an example of use.
+ *
+ * Return value: %TRUE if the input method handled the key event.
+ *
+ * Since: 2.22
+ */
+gboolean
+gtk_entry_im_context_filter_keypress (GtkEntry    *entry,
+                                      GdkEventKey *event)
+{
+  GtkEntryPrivate *priv;
+
+  g_return_val_if_fail (GTK_IS_ENTRY (entry), FALSE);
+
+  priv = entry->priv;
+
+  return gtk_im_context_filter_keypress (priv->im_context, event);
+}
+
+GtkIMContext*
+_gtk_entry_get_im_context (GtkEntry *entry)
+{
+  return entry->priv->im_context;
+}
+
 static gint
 gtk_entry_find_position (GtkEntry *entry,
                         gint      x)
 {
+  GtkEntryPrivate *priv = entry->priv;
   PangoLayout *layout;
   PangoLayoutLine *line;
   gint index;
@@ -3936,15 +5931,15 @@ gtk_entry_find_position (GtkEntry *entry,
   
   layout = gtk_entry_ensure_layout (entry, TRUE);
   text = pango_layout_get_text (layout);
-  cursor_index = g_utf8_offset_to_pointer (text, entry->current_pos) - text;
-  
+  cursor_index = g_utf8_offset_to_pointer (text, priv->current_pos) - text;
+
   line = pango_layout_get_lines_readonly (layout)->data;
   pango_layout_line_x_to_index (line, x * PANGO_SCALE, &index, &trailing);
 
-  if (index >= cursor_index && entry->preedit_length)
+  if (index >= cursor_index && priv->preedit_length)
     {
-      if (index >= cursor_index + entry->preedit_length)
-       index -= entry->preedit_length;
+      if (index >= cursor_index + priv->preedit_length)
+       index -= priv->preedit_length;
       else
        {
          index = cursor_index;
@@ -3964,7 +5959,11 @@ gtk_entry_get_cursor_locations (GtkEntry   *entry,
                                gint       *strong_x,
                                gint       *weak_x)
 {
-  if (!entry->visible && !entry->invisible_char)
+  GtkEntryPrivate *priv = entry->priv;
+  DisplayMode mode = gtk_entry_get_display_mode (entry);
+
+  /* Nothing to display at all, so no cursor is relevant */
+  if (mode == DISPLAY_BLANK)
     {
       if (strong_x)
        *strong_x = 0;
@@ -3981,20 +5980,20 @@ gtk_entry_get_cursor_locations (GtkEntry   *entry,
   
       if (type == CURSOR_STANDARD)
        {
-         index = g_utf8_offset_to_pointer (text, entry->current_pos + entry->preedit_cursor) - text;
+         index = g_utf8_offset_to_pointer (text, priv->current_pos + priv->preedit_cursor) - text;
        }
       else /* type == CURSOR_DND */
        {
-         index = g_utf8_offset_to_pointer (text, entry->dnd_position) - text;
+         index = g_utf8_offset_to_pointer (text, priv->dnd_position) - text;
 
-         if (entry->dnd_position > entry->current_pos)
+         if (priv->dnd_position > priv->current_pos)
            {
-             if (entry->visible)
-               index += entry->preedit_length;
+             if (mode == DISPLAY_NORMAL)
+               index += priv->preedit_length;
              else
                {
-                 gint preedit_len_chars = g_utf8_strlen (text, -1) - entry->text_length;
-                 index += preedit_len_chars * g_unichar_to_utf8 (entry->invisible_char, NULL);
+                 gint preedit_len_chars = g_utf8_strlen (text, -1) - gtk_entry_buffer_get_length (get_buffer (entry));
+                 index += preedit_len_chars * g_unichar_to_utf8 (priv->invisible_char, NULL);
                }
            }
        }
@@ -4012,7 +6011,7 @@ gtk_entry_get_cursor_locations (GtkEntry   *entry,
 static void
 gtk_entry_adjust_scroll (GtkEntry *entry)
 {
-  GtkEntryPrivate *priv = GTK_ENTRY_GET_PRIVATE (entry);
+  GtkEntryPrivate *priv = entry->priv;
   gint min_offset, max_offset;
   gint text_area_width, text_width;
   GtkBorder inner_border;
@@ -4023,12 +6022,12 @@ gtk_entry_adjust_scroll (GtkEntry *entry)
   PangoLayoutLine *line;
   PangoRectangle logical_rect;
 
-  if (!GTK_WIDGET_REALIZED (entry))
+  if (!gtk_widget_get_realized (GTK_WIDGET (entry)))
     return;
 
   _gtk_entry_effective_inner_border (entry, &inner_border);
 
-  gdk_drawable_get_size (entry->text_area, &text_area_width, NULL);
+  text_area_width = gdk_window_get_width (priv->text_area);
   text_area_width -= inner_border.left + inner_border.right;
   if (text_area_width < 0)
     text_area_width = 0;
@@ -4040,7 +6039,7 @@ gtk_entry_adjust_scroll (GtkEntry *entry)
 
   /* Display as much text as we can */
 
-  if (entry->resolved_dir == PANGO_DIRECTION_LTR)
+  if (priv->resolved_dir == PANGO_DIRECTION_LTR)
       xalign = priv->xalign;
   else
       xalign = 1.0 - priv->xalign;
@@ -4058,7 +6057,7 @@ gtk_entry_adjust_scroll (GtkEntry *entry)
       max_offset = min_offset;
     }
 
-  entry->scroll_offset = CLAMP (entry->scroll_offset, min_offset, max_offset);
+  priv->scroll_offset = CLAMP (priv->scroll_offset, min_offset, max_offset);
 
   /* And make sure cursors are on screen. Note that the cursor is
    * actually drawn one pixel into the INNER_BORDER space on
@@ -4076,29 +6075,29 @@ gtk_entry_adjust_scroll (GtkEntry *entry)
 
   gtk_entry_get_cursor_locations (entry, CURSOR_STANDARD, &strong_x, &weak_x);
   
-  strong_xoffset = strong_x - entry->scroll_offset;
+  strong_xoffset = strong_x - priv->scroll_offset;
 
   if (strong_xoffset < 0)
     {
-      entry->scroll_offset += strong_xoffset;
+      priv->scroll_offset += strong_xoffset;
       strong_xoffset = 0;
     }
   else if (strong_xoffset > text_area_width)
     {
-      entry->scroll_offset += strong_xoffset - text_area_width;
+      priv->scroll_offset += strong_xoffset - text_area_width;
       strong_xoffset = text_area_width;
     }
 
-  weak_xoffset = weak_x - entry->scroll_offset;
+  weak_xoffset = weak_x - priv->scroll_offset;
 
   if (weak_xoffset < 0 && strong_xoffset - weak_xoffset <= text_area_width)
     {
-      entry->scroll_offset += weak_xoffset;
+      priv->scroll_offset += weak_xoffset;
     }
   else if (weak_xoffset > text_area_width &&
           strong_xoffset - (weak_xoffset - text_area_width) >= 0)
     {
-      entry->scroll_offset += weak_xoffset - text_area_width;
+      priv->scroll_offset += weak_xoffset - text_area_width;
     }
 
   g_object_notify (G_OBJECT (entry), "scroll-offset");
@@ -4107,26 +6106,35 @@ gtk_entry_adjust_scroll (GtkEntry *entry)
 static void
 gtk_entry_move_adjustments (GtkEntry *entry)
 {
+  GtkWidget *widget = GTK_WIDGET (entry);
+  GtkAllocation allocation;
+  GtkAdjustment *adjustment;
   PangoContext *context;
   PangoFontMetrics *metrics;
+  GtkStyleContext *style_context;
+  GtkStateFlags state;
   gint x, layout_x, border_x, border_y;
   gint char_width;
-  GtkAdjustment *adjustment;
 
   adjustment = g_object_get_qdata (G_OBJECT (entry), quark_cursor_hadjustment);
   if (!adjustment)
     return;
 
+  gtk_widget_get_allocation (widget, &allocation);
+
   /* Cursor position, layout offset, border width, and widget allocation */
   gtk_entry_get_cursor_locations (entry, CURSOR_STANDARD, &x, NULL);
   get_layout_position (entry, &layout_x, NULL);
   _gtk_entry_get_borders (entry, &border_x, &border_y);
-  x += entry->widget.allocation.x + layout_x + border_x;
+  x += allocation.x + layout_x + border_x;
 
   /* Approximate width of a char, so user can see what is ahead/behind */
-  context = gtk_widget_get_pango_context (GTK_WIDGET (entry));
-  metrics = pango_context_get_metrics (context, 
-                                       entry->widget.style->font_desc,
+  context = gtk_widget_get_pango_context (widget);
+  style_context = gtk_widget_get_style_context (widget);
+  state = gtk_widget_get_state_flags (widget);
+
+  metrics = pango_context_get_metrics (context,
+                                       gtk_style_context_get_font (style_context, state),
                                       pango_context_get_language (context));
   char_width = pango_font_metrics_get_approximate_char_width (metrics) / PANGO_SCALE;
 
@@ -4141,6 +6149,7 @@ gtk_entry_move_visually (GtkEntry *entry,
                         gint      start,
                         gint      count)
 {
+  GtkEntryPrivate *priv = entry->priv;
   gint index;
   PangoLayout *layout = gtk_entry_ensure_layout (entry, FALSE);
   const gchar *text;
@@ -4166,7 +6175,7 @@ gtk_entry_move_visually (GtkEntry *entry,
          GdkKeymap *keymap = gdk_keymap_get_for_display (gtk_widget_get_display (GTK_WIDGET (entry)));
          PangoDirection keymap_direction = gdk_keymap_get_direction (keymap);
 
-         strong = keymap_direction == entry->resolved_dir;
+         strong = keymap_direction == priv->resolved_dir;
        }
       
       if (count > 0)
@@ -4198,13 +6207,16 @@ gtk_entry_move_logically (GtkEntry *entry,
                          gint      count)
 {
   gint new_pos = start;
+  guint length;
+
+  length = gtk_entry_buffer_get_length (get_buffer (entry));
 
   /* Prevent any leak of information */
-  if (!entry->visible)
+  if (gtk_entry_get_display_mode (entry) != DISPLAY_NORMAL)
     {
-      new_pos = CLAMP (start + count, 0, entry->text_length);
+      new_pos = CLAMP (start + count, 0, length);
     }
-  else if (entry->text)
+  else
     {
       PangoLayout *layout = gtk_entry_ensure_layout (entry, FALSE);
       PangoLogAttr *log_attrs;
@@ -4212,11 +6224,11 @@ gtk_entry_move_logically (GtkEntry *entry,
 
       pango_layout_get_log_attrs (layout, &log_attrs, &n_attrs);
 
-      while (count > 0 && new_pos < entry->text_length)
+      while (count > 0 && new_pos < length)
        {
          do
            new_pos++;
-         while (new_pos < entry->text_length && !log_attrs[new_pos].is_cursor_position);
+         while (new_pos < length && !log_attrs[new_pos].is_cursor_position);
          
          count--;
        }
@@ -4241,13 +6253,16 @@ gtk_entry_move_forward_word (GtkEntry *entry,
                              gboolean  allow_whitespace)
 {
   gint new_pos = start;
+  guint length;
+
+  length = gtk_entry_buffer_get_length (get_buffer (entry));
 
   /* Prevent any leak of information */
-  if (!entry->visible)
+  if (gtk_entry_get_display_mode (entry) != DISPLAY_NORMAL)
     {
-      new_pos = entry->text_length;
+      new_pos = length;
     }
-  else if (entry->text && (new_pos < entry->text_length))
+  else if (new_pos < length)
     {
       PangoLayout *layout = gtk_entry_ensure_layout (entry, FALSE);
       PangoLogAttr *log_attrs;
@@ -4276,11 +6291,11 @@ gtk_entry_move_backward_word (GtkEntry *entry,
   gint new_pos = start;
 
   /* Prevent any leak of information */
-  if (!entry->visible)
+  if (gtk_entry_get_display_mode (entry) != DISPLAY_NORMAL)
     {
       new_pos = 0;
     }
-  else if (entry->text && start > 0)
+  else if (start > 0)
     {
       PangoLayout *layout = gtk_entry_ensure_layout (entry, FALSE);
       PangoLogAttr *log_attrs;
@@ -4304,6 +6319,7 @@ gtk_entry_move_backward_word (GtkEntry *entry,
 static void
 gtk_entry_delete_whitespace (GtkEntry *entry)
 {
+  GtkEntryPrivate *priv = entry->priv;
   PangoLayout *layout = gtk_entry_ensure_layout (entry, FALSE);
   PangoLogAttr *log_attrs;
   gint n_attrs;
@@ -4311,7 +6327,7 @@ gtk_entry_delete_whitespace (GtkEntry *entry)
 
   pango_layout_get_log_attrs (layout, &log_attrs, &n_attrs);
 
-  start = end = entry->current_pos;
+  start = end = priv->current_pos;
   
   while (start > 0 && log_attrs[start-1].is_white)
     start--;
@@ -4329,8 +6345,9 @@ gtk_entry_delete_whitespace (GtkEntry *entry)
 static void
 gtk_entry_select_word (GtkEntry *entry)
 {
-  gint start_pos = gtk_entry_move_backward_word (entry, entry->current_pos, TRUE);
-  gint end_pos = gtk_entry_move_forward_word (entry, entry->current_pos, TRUE);
+  GtkEntryPrivate *priv = entry->priv;
+  gint start_pos = gtk_entry_move_backward_word (entry, priv->current_pos, TRUE);
+  gint end_pos = gtk_entry_move_forward_word (entry, priv->current_pos, TRUE);
 
   gtk_editable_select_region (GTK_EDITABLE (entry), start_pos, end_pos);
 }
@@ -4341,30 +6358,6 @@ gtk_entry_select_line (GtkEntry *entry)
   gtk_editable_select_region (GTK_EDITABLE (entry), 0, -1);
 }
 
-/*
- * Like gtk_editable_get_chars, but handle not-visible entries
- * correctly.
- */
-static char *    
-gtk_entry_get_public_chars (GtkEntry *entry,
-                           gint      start,
-                           gint      end)
-{
-  if (end < 0)
-    end = entry->text_length;
-  
-  if (entry->visible)
-    return gtk_editable_get_chars (GTK_EDITABLE (entry), start, end);
-  else if (!entry->invisible_char)
-    return g_strdup ("");
-  else
-    {
-      GString *str = g_string_new (NULL);
-      append_char (str, entry->invisible_char, end - start);
-      return g_string_free (str, FALSE);
-    }
-}
-
 static gint
 truncate_multiline (const gchar *text)
 {
@@ -4384,9 +6377,9 @@ paste_received (GtkClipboard *clipboard,
 {
   GtkEntry *entry = GTK_ENTRY (data);
   GtkEditable *editable = GTK_EDITABLE (entry);
-  GtkEntryPrivate *priv = GTK_ENTRY_GET_PRIVATE (entry);
-      
-  if (entry->button == 2)
+  GtkEntryPrivate *priv = entry->priv;
+
+  if (priv->button == 2)
     {
       gint pos, start, end;
       pos = priv->insert_pos;
@@ -4404,15 +6397,16 @@ paste_received (GtkClipboard *clipboard,
 
       completion = gtk_entry_get_completion (entry);
 
-      if (entry->truncate_multiline)
+      if (priv->truncate_multiline)
         length = truncate_multiline (text);
 
       /* only complete if the selection is at the end */
-      popup_completion = (entry->text_length == MAX (entry->current_pos, entry->selection_bound));
+      popup_completion = (gtk_entry_buffer_get_length (get_buffer (entry)) ==
+                          MAX (priv->current_pos, priv->selection_bound));
 
       if (completion)
        {
-         if (GTK_WIDGET_MAPPED (completion->priv->popup_window))
+         if (gtk_widget_get_mapped (completion->priv->popup_window))
            _gtk_entry_completion_popdown (completion);
 
           if (!popup_completion && completion->priv->changed_id > 0)
@@ -4424,7 +6418,7 @@ paste_received (GtkClipboard *clipboard,
       if (gtk_editable_get_selection_bounds (editable, &start, &end))
         gtk_editable_delete_text (editable, start, end);
 
-      pos = entry->current_pos;
+      pos = priv->current_pos;
       gtk_editable_insert_text (editable, text, length, &pos);
       gtk_editable_set_position (editable, pos);
       g_object_thaw_notify (G_OBJECT (entry));
@@ -4458,7 +6452,7 @@ primary_get_cb (GtkClipboard     *clipboard,
   
   if (gtk_editable_get_selection_bounds (GTK_EDITABLE (entry), &start, &end))
     {
-      gchar *str = gtk_entry_get_public_chars (entry, start, end);
+      gchar *str = gtk_entry_get_display_text (entry, start, end);
       gtk_selection_data_set_text (selection_data, str, -1);
       g_free (str);
     }
@@ -4469,8 +6463,9 @@ primary_clear_cb (GtkClipboard *clipboard,
                  gpointer      data)
 {
   GtkEntry *entry = GTK_ENTRY (data);
+  GtkEntryPrivate *priv = entry->priv;
 
-  gtk_editable_select_region (GTK_EDITABLE (entry), entry->current_pos, entry->current_pos);
+  gtk_editable_select_region (GTK_EDITABLE (entry), priv->current_pos, priv->current_pos);
 }
 
 static void
@@ -4482,7 +6477,7 @@ gtk_entry_update_primary_selection (GtkEntry *entry)
   gint start, end;
   gint n_targets;
 
-  if (!GTK_WIDGET_REALIZED (entry))
+  if (!gtk_widget_get_realized (GTK_WIDGET (entry)))
     return;
 
   list = gtk_target_list_new (NULL, 0);
@@ -4508,6 +6503,181 @@ gtk_entry_update_primary_selection (GtkEntry *entry)
   gtk_target_list_unref (list);
 }
 
+static void
+gtk_entry_clear (GtkEntry             *entry,
+                 GtkEntryIconPosition  icon_pos)
+{
+  GtkEntryPrivate *priv = entry->priv;
+  EntryIconInfo *icon_info = priv->icons[icon_pos];
+
+  if (!icon_info || icon_info->storage_type == GTK_IMAGE_EMPTY)
+    return;
+
+  g_object_freeze_notify (G_OBJECT (entry));
+
+  /* Explicitly check, as the pointer may become invalidated
+   * during destruction.
+   */
+  if (GDK_IS_WINDOW (icon_info->window))
+    gdk_window_hide (icon_info->window);
+
+  if (icon_info->pixbuf)
+    {
+      g_object_unref (icon_info->pixbuf);
+      icon_info->pixbuf = NULL;
+    }
+
+  switch (icon_info->storage_type)
+    {
+    case GTK_IMAGE_PIXBUF:
+      g_object_notify (G_OBJECT (entry),
+                       icon_pos == GTK_ENTRY_ICON_PRIMARY ? "primary-icon-pixbuf" : "secondary-icon-pixbuf");
+      break;
+
+    case GTK_IMAGE_STOCK:
+      g_free (icon_info->stock_id);
+      icon_info->stock_id = NULL;
+      g_object_notify (G_OBJECT (entry),
+                       icon_pos == GTK_ENTRY_ICON_PRIMARY ? "primary-icon-stock" : "secondary-icon-stock");
+      break;
+
+    case GTK_IMAGE_ICON_NAME:
+      g_free (icon_info->icon_name);
+      icon_info->icon_name = NULL;
+      g_object_notify (G_OBJECT (entry),
+                       icon_pos == GTK_ENTRY_ICON_PRIMARY ? "primary-icon-name" : "secondary-icon-name");
+      break;
+
+    case GTK_IMAGE_GICON:
+      if (icon_info->gicon)
+        {
+          g_object_unref (icon_info->gicon);
+          icon_info->gicon = NULL;
+        }
+      g_object_notify (G_OBJECT (entry),
+                       icon_pos == GTK_ENTRY_ICON_PRIMARY ? "primary-icon-gicon" : "secondary-icon-gicon");
+      break;
+
+    default:
+      g_assert_not_reached ();
+      break;
+    }
+
+  icon_info->storage_type = GTK_IMAGE_EMPTY;
+  g_object_notify (G_OBJECT (entry),
+                   icon_pos == GTK_ENTRY_ICON_PRIMARY ? "primary-icon-storage-type" : "secondary-icon-storage-type");
+
+  g_object_thaw_notify (G_OBJECT (entry));
+}
+
+static void
+gtk_entry_ensure_pixbuf (GtkEntry             *entry,
+                         GtkEntryIconPosition  icon_pos)
+{
+  GtkEntryPrivate *priv = entry->priv;
+  EntryIconInfo *icon_info = priv->icons[icon_pos];
+  GtkIconInfo *info;
+  GtkIconTheme *icon_theme;
+  GtkSettings *settings;
+  GtkStateFlags state;
+  GtkWidget *widget;
+  GdkScreen *screen;
+  gint width, height;
+
+  if (!icon_info || icon_info->pixbuf)
+    return;
+
+  widget = GTK_WIDGET (entry);
+
+  switch (icon_info->storage_type)
+    {
+    case GTK_IMAGE_EMPTY:
+    case GTK_IMAGE_PIXBUF:
+      break;
+    case GTK_IMAGE_STOCK:
+      state = gtk_widget_get_state_flags (widget);
+      gtk_widget_set_state_flags (widget, 0, TRUE);
+      icon_info->pixbuf = gtk_widget_render_icon_pixbuf (widget,
+                                                         icon_info->stock_id,
+                                                         GTK_ICON_SIZE_MENU);
+      if (!icon_info->pixbuf)
+        icon_info->pixbuf = gtk_widget_render_icon_pixbuf (widget,
+                                                           GTK_STOCK_MISSING_IMAGE,
+                                                           GTK_ICON_SIZE_MENU);
+      gtk_widget_set_state_flags (widget, state, TRUE);
+      break;
+
+    case GTK_IMAGE_ICON_NAME:
+      screen = gtk_widget_get_screen (widget);
+      if (screen)
+        {
+          icon_theme = gtk_icon_theme_get_for_screen (screen);
+          settings = gtk_settings_get_for_screen (screen);
+
+          gtk_icon_size_lookup_for_settings (settings,
+                                             GTK_ICON_SIZE_MENU,
+                                             &width, &height);
+
+          icon_info->pixbuf = gtk_icon_theme_load_icon (icon_theme,
+                                                        icon_info->icon_name,
+                                                        MIN (width, height),
+                                                        0, NULL);
+
+          if (icon_info->pixbuf == NULL)
+            {
+              state = gtk_widget_get_state_flags (widget);
+              gtk_widget_set_state_flags (widget, 0, TRUE);
+              icon_info->pixbuf = gtk_widget_render_icon_pixbuf (widget,
+                                                                 GTK_STOCK_MISSING_IMAGE,
+                                                                 GTK_ICON_SIZE_MENU);
+              gtk_widget_set_state_flags (widget, state, TRUE);
+            }
+        }
+      break;
+
+    case GTK_IMAGE_GICON:
+      screen = gtk_widget_get_screen (widget);
+      if (screen)
+        {
+          icon_theme = gtk_icon_theme_get_for_screen (screen);
+          settings = gtk_settings_get_for_screen (screen);
+
+          gtk_icon_size_lookup_for_settings (settings,
+                                             GTK_ICON_SIZE_MENU,
+                                             &width, &height);
+
+          info = gtk_icon_theme_lookup_by_gicon (icon_theme,
+                                                 icon_info->gicon,
+                                                 MIN (width, height), 
+                                                 GTK_ICON_LOOKUP_USE_BUILTIN);
+          if (info)
+            {
+              icon_info->pixbuf = gtk_icon_info_load_icon (info, NULL);
+              gtk_icon_info_free (info);
+            }
+
+          if (icon_info->pixbuf == NULL)
+            {
+              state = gtk_widget_get_state_flags (widget);
+              gtk_widget_set_state_flags (widget, 0, TRUE);
+              icon_info->pixbuf = gtk_widget_render_icon_pixbuf (widget,
+                                                                 GTK_STOCK_MISSING_IMAGE,
+                                                                 GTK_ICON_SIZE_MENU);
+              gtk_widget_set_state_flags (widget, state, TRUE);
+            }
+        }
+      break;
+
+    default:
+      g_assert_not_reached ();
+      break;
+    }
+    
+  if (icon_info->pixbuf != NULL && icon_info->window != NULL)
+    gdk_window_show_unraised (icon_info->window);
+}
+
+
 /* Public API
  */
 
@@ -4525,33 +6695,155 @@ gtk_entry_new (void)
 }
 
 /**
- * gtk_entry_new_with_max_length:
- * @max: the maximum length of the entry, or 0 for no maximum.
- *   (other than the maximum length of entries.) The value passed in will
- *   be clamped to the range 0-65536.
+ * gtk_entry_new_with_buffer:
+ * @buffer: The buffer to use for the new #GtkEntry.
  *
- * Creates a new #GtkEntry widget with the given maximum length.
- * 
- * Note: the existence of this function is inconsistent
- * with the rest of the GTK+ API. The normal setup would
- * be to just require the user to make an extra call
- * to gtk_entry_set_max_length() instead. It is not
- * expected that this function will be removed, but
- * it would be better practice not to use it.
- * 
- * Return value: a new #GtkEntry.
- **/
+ * Creates a new entry with the specified text buffer.
+ *
+ * Return value: a new #GtkEntry
+ *
+ * Since: 2.18
+ */
 GtkWidget*
-gtk_entry_new_with_max_length (gint max)
+gtk_entry_new_with_buffer (GtkEntryBuffer *buffer)
 {
-  GtkEntry *entry;
+  g_return_val_if_fail (GTK_IS_ENTRY_BUFFER (buffer), NULL);
+  return g_object_new (GTK_TYPE_ENTRY, "buffer", buffer, NULL);
+}
 
-  max = CLAMP (max, 0, MAX_SIZE);
+static GtkEntryBuffer*
+get_buffer (GtkEntry *entry)
+{
+  GtkEntryPrivate *priv = entry->priv;
+
+  if (priv->buffer == NULL)
+    {
+      GtkEntryBuffer *buffer;
+      buffer = gtk_entry_buffer_new (NULL, 0);
+      gtk_entry_set_buffer (entry, buffer);
+      g_object_unref (buffer);
+    }
+
+  return priv->buffer;
+}
+
+/**
+ * gtk_entry_get_buffer:
+ * @entry: a #GtkEntry
+ *
+ * Get the #GtkEntryBuffer object which holds the text for
+ * this widget.
+ *
+ * Since: 2.18
+ *
+ * Returns: (transfer none): A #GtkEntryBuffer object.
+ */
+GtkEntryBuffer*
+gtk_entry_get_buffer (GtkEntry *entry)
+{
+  g_return_val_if_fail (GTK_IS_ENTRY (entry), NULL);
+
+  return get_buffer (entry);
+}
+
+/**
+ * gtk_entry_set_buffer:
+ * @entry: a #GtkEntry
+ * @buffer: a #GtkEntryBuffer
+ *
+ * Set the #GtkEntryBuffer object which holds the text for
+ * this widget.
+ *
+ * Since: 2.18
+ */
+void
+gtk_entry_set_buffer (GtkEntry       *entry,
+                      GtkEntryBuffer *buffer)
+{
+  GtkEntryPrivate *priv;
+  GObject *obj;
+
+  g_return_if_fail (GTK_IS_ENTRY (entry));
+
+  priv = entry->priv;
+
+  if (buffer)
+    {
+      g_return_if_fail (GTK_IS_ENTRY_BUFFER (buffer));
+      g_object_ref (buffer);
+    }
 
-  entry = g_object_new (GTK_TYPE_ENTRY, NULL);
-  entry->text_max_length = max;
+  if (priv->buffer)
+    {
+      buffer_disconnect_signals (entry);
+      g_object_unref (priv->buffer);
+    }
+
+  priv->buffer = buffer;
+
+  if (priv->buffer)
+     buffer_connect_signals (entry);
+
+  obj = G_OBJECT (entry);
+  g_object_freeze_notify (obj);
+  g_object_notify (obj, "buffer");
+  g_object_notify (obj, "text");
+  g_object_notify (obj, "text-length");
+  g_object_notify (obj, "max-length");
+  g_object_notify (obj, "visibility");
+  g_object_notify (obj, "invisible-char");
+  g_object_notify (obj, "invisible-char-set");
+  g_object_thaw_notify (obj);
+
+  gtk_editable_set_position (GTK_EDITABLE (entry), 0);
+  gtk_entry_recompute (entry);
+}
+
+/**
+ * gtk_entry_get_text_area:
+ * @entry: a #GtkEntry
+ * @text_area: (out): Return location for the text area.
+ *
+ * Gets the area where the entry's text is drawn. This function is
+ * useful when drawing something to the entry in a draw callback.
+ *
+ * If the entry is not realized, @text_area is filled with zeros.
+ *
+ * See also gtk_entry_get_icon_area().
+ *
+ * Since: 3.0
+ **/
+void
+gtk_entry_get_text_area (GtkEntry     *entry,
+                         GdkRectangle *text_area)
+{
+  GtkEntryPrivate *priv;
+
+  g_return_if_fail (GTK_IS_ENTRY (entry));
+  g_return_if_fail (text_area != NULL);
+
+  priv = entry->priv;
+
+  if (priv->text_area)
+    {
+      GtkAllocation allocation;
+      gint x, y;
+
+      gtk_widget_get_allocation (GTK_WIDGET (entry), &allocation);
+      gdk_window_get_position (priv->text_area, &x, &y);
 
-  return GTK_WIDGET (entry);
+      text_area->x = x - allocation.x;
+      text_area->y = y - allocation.y;
+      text_area->width = gdk_window_get_width (priv->text_area);
+      text_area->height = gdk_window_get_height (priv->text_area);
+    }
+  else
+    {
+      text_area->x = 0;
+      text_area->y = 0;
+      text_area->width = 0;
+      text_area->height = 0;
+    }
 }
 
 /**
@@ -4561,6 +6853,8 @@ gtk_entry_new_with_max_length (gint max)
  *
  * Sets the text in the widget to the given
  * value, replacing the current contents.
+ *
+ * See gtk_entry_buffer_set_text().
  */
 void
 gtk_entry_set_text (GtkEntry    *entry,
@@ -4575,7 +6869,7 @@ gtk_entry_set_text (GtkEntry    *entry,
   /* Actually setting the text will affect the cursor and selection;
    * if the contents don't actually change, this will look odd to the user.
    */
-  if (strcmp (entry->text, text) == 0)
+  if (strcmp (gtk_entry_buffer_get_text (get_buffer (entry)), text) == 0)
     return;
 
   completion = gtk_entry_get_completion (entry);
@@ -4585,7 +6879,6 @@ gtk_entry_set_text (GtkEntry    *entry,
   begin_change (entry);
   g_object_freeze_notify (G_OBJECT (entry));
   gtk_editable_delete_text (GTK_EDITABLE (entry), 0, -1);
-
   tmp_pos = 0;
   gtk_editable_insert_text (GTK_EDITABLE (entry), text, strlen (text), &tmp_pos);
   g_object_thaw_notify (G_OBJECT (entry));
@@ -4595,73 +6888,6 @@ gtk_entry_set_text (GtkEntry    *entry,
     g_signal_handler_unblock (entry, completion->priv->changed_id);
 }
 
-/**
- * gtk_entry_append_text:
- * @entry: a #GtkEntry
- * @text: the text to append
- *
- * Appends the given text to the contents of the widget.
- *
- * Deprecated: 2.0: Use gtk_editable_insert_text() instead.
- */
-void
-gtk_entry_append_text (GtkEntry *entry,
-                      const gchar *text)
-{
-  gint tmp_pos;
-
-  g_return_if_fail (GTK_IS_ENTRY (entry));
-  g_return_if_fail (text != NULL);
-
-  tmp_pos = entry->text_length;
-  gtk_editable_insert_text (GTK_EDITABLE (entry), text, -1, &tmp_pos);
-}
-
-/**
- * gtk_entry_prepend_text:
- * @entry: a #GtkEntry
- * @text: the text to prepend
- *
- * Prepends the given text to the contents of the widget.
- *
- * Deprecated: 2.0: Use gtk_editable_insert_text() instead.
- */
-void
-gtk_entry_prepend_text (GtkEntry *entry,
-                       const gchar *text)
-{
-  gint tmp_pos;
-
-  g_return_if_fail (GTK_IS_ENTRY (entry));
-  g_return_if_fail (text != NULL);
-
-  tmp_pos = 0;
-  gtk_editable_insert_text (GTK_EDITABLE (entry), text, -1, &tmp_pos);
-}
-
-/**
- * gtk_entry_set_position:
- * @entry: a #GtkEntry
- * @position:  the position of the cursor. The cursor is displayed
- *    before the character with the given (base 0) index in the widget. 
- *    The value must be less than or equal to the number of characters 
- *    in the widget. A value of -1 indicates that the position should
- *    be set after the last character in the entry. Note that this 
- *    position is in characters, not in bytes.
- *
- * Sets the cursor position in an entry to the given value. 
- *
- * Deprecated: 2.0: Use gtk_editable_set_position() instead.
- */
-void
-gtk_entry_set_position (GtkEntry *entry,
-                       gint       position)
-{
-  g_return_if_fail (GTK_IS_ENTRY (entry));
-
-  gtk_editable_set_position (GTK_EDITABLE (entry), position);
-}
-
 /**
  * gtk_entry_set_visibility:
  * @entry: a #GtkEntry
@@ -4681,13 +6907,17 @@ void
 gtk_entry_set_visibility (GtkEntry *entry,
                          gboolean visible)
 {
+  GtkEntryPrivate *priv;
+
   g_return_if_fail (GTK_IS_ENTRY (entry));
 
+  priv = entry->priv;
+
   visible = visible != FALSE;
 
-  if (entry->visible != visible)
+  if (priv->visible != visible)
     {
-      entry->visible = visible;
+      priv->visible = visible;
 
       g_object_notify (G_OBJECT (entry), "visibility");
       gtk_entry_recompute (entry);
@@ -4708,7 +6938,7 @@ gtk_entry_get_visibility (GtkEntry *entry)
 {
   g_return_val_if_fail (GTK_IS_ENTRY (entry), FALSE);
 
-  return entry->visible;
+  return entry->priv->visible;
 }
 
 /**
@@ -4732,7 +6962,7 @@ gtk_entry_set_invisible_char (GtkEntry *entry,
 
   g_return_if_fail (GTK_IS_ENTRY (entry));
 
-  priv = GTK_ENTRY_GET_PRIVATE (entry);
+  priv = entry->priv;
 
   if (!priv->invisible_char_set)
     {
@@ -4740,10 +6970,10 @@ gtk_entry_set_invisible_char (GtkEntry *entry,
       g_object_notify (G_OBJECT (entry), "invisible-char-set");
     }
 
-  if (ch == entry->invisible_char)
+  if (ch == priv->invisible_char)
     return;
 
-  entry->invisible_char = ch;
+  priv->invisible_char = ch;
   g_object_notify (G_OBJECT (entry), "invisible-char");
   gtk_entry_recompute (entry);  
 }
@@ -4763,7 +6993,7 @@ gtk_entry_get_invisible_char (GtkEntry *entry)
 {
   g_return_val_if_fail (GTK_IS_ENTRY (entry), 0);
 
-  return entry->invisible_char;
+  return entry->priv->invisible_char;
 }
 
 /**
@@ -4784,7 +7014,7 @@ gtk_entry_unset_invisible_char (GtkEntry *entry)
 
   g_return_if_fail (GTK_IS_ENTRY (entry));
 
-  priv = GTK_ENTRY_GET_PRIVATE (entry);
+  priv = entry->priv;
 
   if (!priv->invisible_char_set)
     return;
@@ -4792,9 +7022,9 @@ gtk_entry_unset_invisible_char (GtkEntry *entry)
   priv->invisible_char_set = FALSE;
   ch = find_invisible_char (GTK_WIDGET (entry));
 
-  if (entry->invisible_char != ch)
+  if (priv->invisible_char != ch)
     {
-      entry->invisible_char = ch;
+      priv->invisible_char = ch;
       g_object_notify (G_OBJECT (entry), "invisible-char");
     }
 
@@ -4802,26 +7032,6 @@ gtk_entry_unset_invisible_char (GtkEntry *entry)
   gtk_entry_recompute (entry);
 }
 
-/**
- * gtk_entry_set_editable:
- * @entry: a #GtkEntry
- * @editable: %TRUE if the user is allowed to edit the text
- *   in the widget
- *
- * Determines if the user can edit the text in the editable
- * widget or not. 
- *
- * Deprecated: 2.0: Use gtk_editable_set_editable() instead.
- */
-void
-gtk_entry_set_editable (GtkEntry *entry,
-                       gboolean  editable)
-{
-  g_return_if_fail (GTK_IS_ENTRY (entry));
-
-  gtk_editable_set_editable (GTK_EDITABLE (entry), editable);
-}
-
 /**
  * gtk_entry_set_overwrite_mode:
  * @entry: a #GtkEntry
@@ -4835,9 +7045,11 @@ void
 gtk_entry_set_overwrite_mode (GtkEntry *entry,
                               gboolean  overwrite)
 {
+  GtkEntryPrivate *priv = entry->priv;
+
   g_return_if_fail (GTK_IS_ENTRY (entry));
-  
-  if (entry->overwrite_mode == overwrite) 
+
+  if (priv->overwrite_mode == overwrite)
     return;
   
   gtk_entry_toggle_overwrite (entry);
@@ -4860,7 +7072,7 @@ gtk_entry_get_overwrite_mode (GtkEntry *entry)
 {
   g_return_val_if_fail (GTK_IS_ENTRY (entry), FALSE);
 
-  return entry->overwrite_mode;
+  return entry->priv->overwrite_mode;
 }
 
 /**
@@ -4870,6 +7082,12 @@ gtk_entry_get_overwrite_mode (GtkEntry *entry)
  * Retrieves the contents of the entry widget.
  * See also gtk_editable_get_chars().
  *
+ * This is equivalent to:
+ *
+ * <informalexample><programlisting>
+ * gtk_entry_buffer_get_text (gtk_entry_get_buffer (entry));
+ * </programlisting></informalexample>
+ *
  * Return value: a pointer to the contents of the widget as a
  *      string. This string points to internally allocated
  *      storage in the widget and must not be freed, modified or
@@ -4880,29 +7098,7 @@ gtk_entry_get_text (GtkEntry *entry)
 {
   g_return_val_if_fail (GTK_IS_ENTRY (entry), NULL);
 
-  return entry->text;
-}
-
-/**
- * gtk_entry_select_region:
- * @entry: a #GtkEntry
- * @start: the starting position
- * @end: the end position
- *
- * Selects a region of text. The characters that are selected are 
- * those characters at positions from @start_pos up to, but not 
- * including @end_pos. If @end_pos is negative, then the the characters 
- * selected will be those characters from @start_pos to the end of 
- * the text. 
- *
- * Deprecated: 2.0: Use gtk_editable_select_region() instead.
- */
-void       
-gtk_entry_select_region  (GtkEntry       *entry,
-                         gint            start,
-                         gint            end)
-{
-  gtk_editable_select_region (GTK_EDITABLE (entry), start, end);
+  return gtk_entry_buffer_get_text (get_buffer (entry));
 }
 
 /**
@@ -4915,20 +7111,19 @@ gtk_entry_select_region  (GtkEntry       *entry,
  * Sets the maximum allowed length of the contents of the widget. If
  * the current contents are longer than the given length, then they
  * will be truncated to fit.
+ *
+ * This is equivalent to:
+ *
+ * <informalexample><programlisting>
+ * gtk_entry_buffer_set_max_length (gtk_entry_get_buffer (entry), max);
+ * </programlisting></informalexample>
  **/
 void
 gtk_entry_set_max_length (GtkEntry     *entry,
                           gint          max)
 {
   g_return_if_fail (GTK_IS_ENTRY (entry));
-
-  max = CLAMP (max, 0, MAX_SIZE);
-
-  if (max > 0 && entry->text_length > max)
-    gtk_editable_delete_text (GTK_EDITABLE (entry), max, -1);
-  
-  entry->text_max_length = max;
-  g_object_notify (G_OBJECT (entry), "max-length");
+  gtk_entry_buffer_set_max_length (get_buffer (entry), max);
 }
 
 /**
@@ -4938,6 +7133,12 @@ gtk_entry_set_max_length (GtkEntry     *entry,
  * Retrieves the maximum allowed length of the text in
  * @entry. See gtk_entry_set_max_length().
  *
+ * This is equivalent to:
+ *
+ * <informalexample><programlisting>
+ * gtk_entry_buffer_get_max_length (gtk_entry_get_buffer (entry));
+ * </programlisting></informalexample>
+ *
  * Return value: the maximum allowed number of characters
  *               in #GtkEntry, or 0 if there is no maximum.
  **/
@@ -4946,7 +7147,7 @@ gtk_entry_get_max_length (GtkEntry *entry)
 {
   g_return_val_if_fail (GTK_IS_ENTRY (entry), 0);
 
-  return entry->text_max_length;
+  return gtk_entry_buffer_get_max_length (get_buffer (entry));
 }
 
 /**
@@ -4956,6 +7157,12 @@ gtk_entry_get_max_length (GtkEntry *entry)
  * Retrieves the current length of the text in
  * @entry. 
  *
+ * This is equivalent to:
+ *
+ * <informalexample><programlisting>
+ * gtk_entry_buffer_get_length (gtk_entry_get_buffer (entry));
+ * </programlisting></informalexample>
+ *
  * Return value: the current number of characters
  *               in #GtkEntry, or 0 if there are none.
  *
@@ -4966,7 +7173,7 @@ gtk_entry_get_text_length (GtkEntry *entry)
 {
   g_return_val_if_fail (GTK_IS_ENTRY (entry), 0);
 
-  return entry->text_length;
+  return gtk_entry_buffer_get_length (get_buffer (entry));
 }
 
 /**
@@ -4987,12 +7194,17 @@ void
 gtk_entry_set_activates_default (GtkEntry *entry,
                                  gboolean  setting)
 {
+  GtkEntryPrivate *priv;
+
   g_return_if_fail (GTK_IS_ENTRY (entry));
+
+  priv = entry->priv;
+
   setting = setting != FALSE;
 
-  if (setting != entry->activates_default)
+  if (setting != priv->activates_default)
     {
-      entry->activates_default = setting;
+      priv->activates_default = setting;
       g_object_notify (G_OBJECT (entry), "activates-default");
     }
 }
@@ -5010,7 +7222,7 @@ gtk_entry_get_activates_default (GtkEntry *entry)
 {
   g_return_val_if_fail (GTK_IS_ENTRY (entry), FALSE);
 
-  return entry->activates_default;
+  return entry->priv->activates_default;
 }
 
 /**
@@ -5028,11 +7240,15 @@ void
 gtk_entry_set_width_chars (GtkEntry *entry,
                            gint      n_chars)
 {
+  GtkEntryPrivate *priv;
+
   g_return_if_fail (GTK_IS_ENTRY (entry));
 
-  if (entry->width_chars != n_chars)
+  priv = entry->priv;
+
+  if (priv->width_chars != n_chars)
     {
-      entry->width_chars = n_chars;
+      priv->width_chars = n_chars;
       g_object_notify (G_OBJECT (entry), "width-chars");
       gtk_widget_queue_resize (GTK_WIDGET (entry));
     }
@@ -5051,7 +7267,7 @@ gtk_entry_get_width_chars (GtkEntry *entry)
 {
   g_return_val_if_fail (GTK_IS_ENTRY (entry), 0);
 
-  return entry->width_chars;
+  return entry->priv->width_chars;
 }
 
 /**
@@ -5065,15 +7281,19 @@ void
 gtk_entry_set_has_frame (GtkEntry *entry,
                          gboolean  setting)
 {
+  GtkEntryPrivate *priv;
+
   g_return_if_fail (GTK_IS_ENTRY (entry));
 
+  priv = entry->priv;
+
   setting = (setting != FALSE);
 
-  if (entry->has_frame == setting)
+  if (priv->has_frame == setting)
     return;
 
   gtk_widget_queue_resize (GTK_WIDGET (entry));
-  entry->has_frame = setting;
+  priv->has_frame = setting;
   g_object_notify (G_OBJECT (entry), "has-frame");
 }
 
@@ -5090,13 +7310,13 @@ gtk_entry_get_has_frame (GtkEntry *entry)
 {
   g_return_val_if_fail (GTK_IS_ENTRY (entry), FALSE);
 
-  return entry->has_frame;
+  return entry->priv->has_frame;
 }
 
 /**
  * gtk_entry_set_inner_border:
  * @entry: a #GtkEntry
- * @border: a #GtkBorder, or %NULL
+ * @border: (allow-none): a #GtkBorder, or %NULL
  *
  * Sets %entry's inner-border property to %border, or clears it if %NULL
  * is passed. The inner-border is the area around the entry's text, but
@@ -5134,7 +7354,7 @@ gtk_entry_set_inner_border (GtkEntry        *entry,
  * This function returns the entry's #GtkEntry:inner-border property. See
  * gtk_entry_set_inner_border() for more information.
  *
- * Return value: the entry's #GtkBorder, or %NULL if none was set.
+ * Return value: (transfer none): the entry's #GtkBorder, or %NULL if none was set.
  *
  * Since: 2.10
  **/
@@ -5160,8 +7380,8 @@ gtk_entry_get_inner_border (GtkEntry *entry)
  * gtk_entry_layout_index_to_text_index() and
  * gtk_entry_text_index_to_layout_index() are needed to convert byte
  * indices in the layout to byte indices in the entry contents.
- * 
- * Return value: the #PangoLayout for this entry
+ *
+ * Return value: (transfer none): the #PangoLayout for this entry
  **/
 PangoLayout*
 gtk_entry_get_layout (GtkEntry *entry)
@@ -5192,20 +7412,23 @@ gint
 gtk_entry_layout_index_to_text_index (GtkEntry *entry,
                                       gint      layout_index)
 {
+  GtkEntryPrivate *priv;
   PangoLayout *layout;
   const gchar *text;
   gint cursor_index;
   
   g_return_val_if_fail (GTK_IS_ENTRY (entry), 0);
 
+  priv = entry->priv;
+
   layout = gtk_entry_ensure_layout (entry, TRUE);
   text = pango_layout_get_text (layout);
-  cursor_index = g_utf8_offset_to_pointer (text, entry->current_pos) - text;
-  
-  if (layout_index >= cursor_index && entry->preedit_length)
+  cursor_index = g_utf8_offset_to_pointer (text, priv->current_pos) - text;
+
+  if (layout_index >= cursor_index && priv->preedit_length)
     {
-      if (layout_index >= cursor_index + entry->preedit_length)
-       layout_index -= entry->preedit_length;
+      if (layout_index >= cursor_index + priv->preedit_length)
+       layout_index -= priv->preedit_length;
       else
         layout_index = cursor_index;
     }
@@ -5228,17 +7451,21 @@ gint
 gtk_entry_text_index_to_layout_index (GtkEntry *entry,
                                       gint      text_index)
 {
+  GtkEntryPrivate *priv;
   PangoLayout *layout;
   const gchar *text;
   gint cursor_index;
+
   g_return_val_if_fail (GTK_IS_ENTRY (entry), 0);
 
+  priv = entry->priv;
+
   layout = gtk_entry_ensure_layout (entry, TRUE);
   text = pango_layout_get_text (layout);
-  cursor_index = g_utf8_offset_to_pointer (text, entry->current_pos) - text;
-  
+  cursor_index = g_utf8_offset_to_pointer (text, priv->current_pos) - text;
+
   if (text_index > cursor_index)
-    text_index += entry->preedit_length;
+    text_index += priv->preedit_length;
 
   return text_index;
 }
@@ -5246,8 +7473,8 @@ gtk_entry_text_index_to_layout_index (GtkEntry *entry,
 /**
  * gtk_entry_get_layout_offsets:
  * @entry: a #GtkEntry
- * @x: location to store X offset of layout, or %NULL
- * @y: location to store Y offset of layout, or %NULL
+ * @x: (out) (allow-none): location to store X offset of layout, or %NULL
+ * @y: (out) (allow-none): location to store Y offset of layout, or %NULL
  *
  *
  * Obtains the position of the #PangoLayout used to render text
@@ -5283,7 +7510,7 @@ gtk_entry_get_layout_offsets (GtkEntry *entry,
   get_layout_position (entry, x, y);
 
   /* convert to widget coords */
-  get_text_area_size (entry, &text_area_x, &text_area_y, NULL, NULL);
+  gtk_entry_get_text_area_size (entry, &text_area_x, &text_area_y, NULL, NULL);
   
   if (x)
     *x += text_area_x;
@@ -5309,10 +7536,10 @@ void
 gtk_entry_set_alignment (GtkEntry *entry, gfloat xalign)
 {
   GtkEntryPrivate *priv;
-  
+
   g_return_if_fail (GTK_IS_ENTRY (entry));
 
-  priv = GTK_ENTRY_GET_PRIVATE (entry);
+  priv = entry->priv;
 
   if (xalign < 0.0)
     xalign = 0.0;
@@ -5342,15 +7569,996 @@ gtk_entry_set_alignment (GtkEntry *entry, gfloat xalign)
 gfloat
 gtk_entry_get_alignment (GtkEntry *entry)
 {
+  g_return_val_if_fail (GTK_IS_ENTRY (entry), 0.0);
+
+  return entry->priv->xalign;
+}
+
+/**
+ * gtk_entry_set_icon_from_pixbuf:
+ * @entry: a #GtkEntry
+ * @icon_pos: Icon position
+ * @pixbuf: (allow-none): A #GdkPixbuf, or %NULL
+ *
+ * Sets the icon shown in the specified position using a pixbuf.
+ *
+ * If @pixbuf is %NULL, no icon will be shown in the specified position.
+ *
+ * Since: 2.16
+ */
+void
+gtk_entry_set_icon_from_pixbuf (GtkEntry             *entry,
+                                GtkEntryIconPosition  icon_pos,
+                                GdkPixbuf            *pixbuf)
+{
+  GtkEntryPrivate *priv;
+  EntryIconInfo *icon_info;
+
+  g_return_if_fail (GTK_IS_ENTRY (entry));
+  g_return_if_fail (IS_VALID_ICON_POSITION (icon_pos));
+
+  priv = entry->priv;
+
+  if ((icon_info = priv->icons[icon_pos]) == NULL)
+    icon_info = construct_icon_info (GTK_WIDGET (entry), icon_pos);
+
+  g_object_freeze_notify (G_OBJECT (entry));
+
+  if (pixbuf)
+    g_object_ref (pixbuf);
+
+  gtk_entry_clear (entry, icon_pos);
+
+  if (pixbuf)
+    {
+      icon_info->storage_type = GTK_IMAGE_PIXBUF;
+      icon_info->pixbuf = pixbuf;
+
+      if (icon_pos == GTK_ENTRY_ICON_PRIMARY)
+        {
+          g_object_notify (G_OBJECT (entry), "primary-icon-pixbuf");
+          g_object_notify (G_OBJECT (entry), "primary-icon-storage-type");
+        }
+      else
+        {
+          g_object_notify (G_OBJECT (entry), "secondary-icon-pixbuf");
+          g_object_notify (G_OBJECT (entry), "secondary-icon-storage-type");
+        }
+
+      if (gtk_widget_get_mapped (GTK_WIDGET (entry)))
+          gdk_window_show_unraised (icon_info->window);
+    }
+
+  gtk_entry_ensure_pixbuf (entry, icon_pos);
+  
+  if (gtk_widget_get_visible (GTK_WIDGET (entry)))
+    gtk_widget_queue_resize (GTK_WIDGET (entry));
+
+  g_object_thaw_notify (G_OBJECT (entry));
+}
+
+/**
+ * gtk_entry_set_icon_from_stock:
+ * @entry: A #GtkEntry
+ * @icon_pos: Icon position
+ * @stock_id: (allow-none): The name of the stock item, or %NULL
+ *
+ * Sets the icon shown in the entry at the specified position from
+ * a stock image.
+ *
+ * If @stock_id is %NULL, no icon will be shown in the specified position.
+ *
+ * Since: 2.16
+ */
+void
+gtk_entry_set_icon_from_stock (GtkEntry             *entry,
+                               GtkEntryIconPosition  icon_pos,
+                               const gchar          *stock_id)
+{
+  GtkEntryPrivate *priv;
+  EntryIconInfo *icon_info;
+  gchar *new_id;
+
+  g_return_if_fail (GTK_IS_ENTRY (entry));
+  g_return_if_fail (IS_VALID_ICON_POSITION (icon_pos));
+
+  priv = entry->priv;
+
+  if ((icon_info = priv->icons[icon_pos]) == NULL)
+    icon_info = construct_icon_info (GTK_WIDGET (entry), icon_pos);
+
+  g_object_freeze_notify (G_OBJECT (entry));
+
+  /* need to dup before clearing */
+  new_id = g_strdup (stock_id);
+
+  gtk_entry_clear (entry, icon_pos);
+
+  if (new_id != NULL)
+    {
+      icon_info->storage_type = GTK_IMAGE_STOCK;
+      icon_info->stock_id = new_id;
+
+      if (icon_pos == GTK_ENTRY_ICON_PRIMARY)
+        {
+          g_object_notify (G_OBJECT (entry), "primary-icon-stock");
+          g_object_notify (G_OBJECT (entry), "primary-icon-storage-type");
+        }
+      else
+        {
+          g_object_notify (G_OBJECT (entry), "secondary-icon-stock");
+          g_object_notify (G_OBJECT (entry), "secondary-icon-storage-type");
+        }
+
+      if (gtk_widget_get_mapped (GTK_WIDGET (entry)))
+          gdk_window_show_unraised (icon_info->window);
+    }
+
+  gtk_entry_ensure_pixbuf (entry, icon_pos);
+
+  if (gtk_widget_get_visible (GTK_WIDGET (entry)))
+    gtk_widget_queue_resize (GTK_WIDGET (entry));
+
+  g_object_thaw_notify (G_OBJECT (entry));
+}
+
+/**
+ * gtk_entry_set_icon_from_icon_name:
+ * @entry: A #GtkEntry
+ * @icon_pos: The position at which to set the icon
+ * @icon_name: (allow-none): An icon name, or %NULL
+ *
+ * Sets the icon shown in the entry at the specified position
+ * from the current icon theme.
+ *
+ * If the icon name isn't known, a "broken image" icon will be displayed
+ * instead.
+ *
+ * If @icon_name is %NULL, no icon will be shown in the specified position.
+ *
+ * Since: 2.16
+ */
+void
+gtk_entry_set_icon_from_icon_name (GtkEntry             *entry,
+                                   GtkEntryIconPosition  icon_pos,
+                                   const gchar          *icon_name)
+{
+  GtkEntryPrivate *priv;
+  EntryIconInfo *icon_info;
+  gchar *new_name;
+
+  g_return_if_fail (GTK_IS_ENTRY (entry));
+  g_return_if_fail (IS_VALID_ICON_POSITION (icon_pos));
+
+  priv = entry->priv;
+
+  if ((icon_info = priv->icons[icon_pos]) == NULL)
+    icon_info = construct_icon_info (GTK_WIDGET (entry), icon_pos);
+
+  g_object_freeze_notify (G_OBJECT (entry));
+
+  /* need to dup before clearing */
+  new_name = g_strdup (icon_name);
+
+  gtk_entry_clear (entry, icon_pos);
+
+  if (new_name != NULL)
+    {
+      icon_info->storage_type = GTK_IMAGE_ICON_NAME;
+      icon_info->icon_name = new_name;
+
+      if (icon_pos == GTK_ENTRY_ICON_PRIMARY)
+        {
+          g_object_notify (G_OBJECT (entry), "primary-icon-name");
+          g_object_notify (G_OBJECT (entry), "primary-icon-storage-type");
+        }
+      else
+        {
+          g_object_notify (G_OBJECT (entry), "secondary-icon-name");
+          g_object_notify (G_OBJECT (entry), "secondary-icon-storage-type");
+        }
+
+      if (gtk_widget_get_mapped (GTK_WIDGET (entry)))
+          gdk_window_show_unraised (icon_info->window);
+    }
+
+  gtk_entry_ensure_pixbuf (entry, icon_pos);
+
+  if (gtk_widget_get_visible (GTK_WIDGET (entry)))
+    gtk_widget_queue_resize (GTK_WIDGET (entry));
+
+  g_object_thaw_notify (G_OBJECT (entry));
+}
+
+/**
+ * gtk_entry_set_icon_from_gicon:
+ * @entry: A #GtkEntry
+ * @icon_pos: The position at which to set the icon
+ * @icon: (allow-none): The icon to set, or %NULL
+ *
+ * Sets the icon shown in the entry at the specified position
+ * from the current icon theme.
+ * If the icon isn't known, a "broken image" icon will be displayed
+ * instead.
+ *
+ * If @icon is %NULL, no icon will be shown in the specified position.
+ *
+ * Since: 2.16
+ */
+void
+gtk_entry_set_icon_from_gicon (GtkEntry             *entry,
+                               GtkEntryIconPosition  icon_pos,
+                               GIcon                *icon)
+{
+  GtkEntryPrivate *priv;
+  EntryIconInfo *icon_info;
+
+  g_return_if_fail (GTK_IS_ENTRY (entry));
+  g_return_if_fail (IS_VALID_ICON_POSITION (icon_pos));
+
+  priv = entry->priv;
+
+  if ((icon_info = priv->icons[icon_pos]) == NULL)
+    icon_info = construct_icon_info (GTK_WIDGET (entry), icon_pos);
+
+  g_object_freeze_notify (G_OBJECT (entry));
+
+  /* need to ref before clearing */
+  if (icon)
+    g_object_ref (icon);
+
+  gtk_entry_clear (entry, icon_pos);
+
+  if (icon)
+    {
+      icon_info->storage_type = GTK_IMAGE_GICON;
+      icon_info->gicon = icon;
+
+      if (icon_pos == GTK_ENTRY_ICON_PRIMARY)
+        {
+          g_object_notify (G_OBJECT (entry), "primary-icon-gicon");
+          g_object_notify (G_OBJECT (entry), "primary-icon-storage-type");
+        }
+      else
+        {
+          g_object_notify (G_OBJECT (entry), "secondary-icon-gicon");
+          g_object_notify (G_OBJECT (entry), "secondary-icon-storage-type");
+        }
+
+      if (gtk_widget_get_mapped (GTK_WIDGET (entry)))
+          gdk_window_show_unraised (icon_info->window);
+    }
+
+  gtk_entry_ensure_pixbuf (entry, icon_pos);
+
+  if (gtk_widget_get_visible (GTK_WIDGET (entry)))
+    gtk_widget_queue_resize (GTK_WIDGET (entry));
+
+  g_object_thaw_notify (G_OBJECT (entry));
+}
+
+/**
+ * gtk_entry_set_icon_activatable:
+ * @entry: A #GtkEntry
+ * @icon_pos: Icon position
+ * @activatable: %TRUE if the icon should be activatable
+ *
+ * Sets whether the icon is activatable.
+ *
+ * Since: 2.16
+ */
+void
+gtk_entry_set_icon_activatable (GtkEntry             *entry,
+                                GtkEntryIconPosition  icon_pos,
+                                gboolean              activatable)
+{
+  GtkEntryPrivate *priv;
+  EntryIconInfo *icon_info;
+
+  g_return_if_fail (GTK_IS_ENTRY (entry));
+  g_return_if_fail (IS_VALID_ICON_POSITION (icon_pos));
+
+  priv = entry->priv;
+
+  if ((icon_info = priv->icons[icon_pos]) == NULL)
+    icon_info = construct_icon_info (GTK_WIDGET (entry), icon_pos);
+
+  activatable = activatable != FALSE;
+
+  if (icon_info->nonactivatable != !activatable)
+    {
+      icon_info->nonactivatable = !activatable;
+
+      if (gtk_widget_get_realized (GTK_WIDGET (entry)))
+        update_cursors (GTK_WIDGET (entry));
+
+      g_object_notify (G_OBJECT (entry),
+                       icon_pos == GTK_ENTRY_ICON_PRIMARY ? "primary-icon-activatable" : "secondary-icon-activatable");
+    }
+}
+
+/**
+ * gtk_entry_get_icon_activatable:
+ * @entry: a #GtkEntry
+ * @icon_pos: Icon position
+ *
+ * Returns whether the icon is activatable.
+ *
+ * Returns: %TRUE if the icon is activatable.
+ *
+ * Since: 2.16
+ */
+gboolean
+gtk_entry_get_icon_activatable (GtkEntry             *entry,
+                                GtkEntryIconPosition  icon_pos)
+{
+  GtkEntryPrivate *priv;
+  EntryIconInfo *icon_info;
+
+  g_return_val_if_fail (GTK_IS_ENTRY (entry), FALSE);
+  g_return_val_if_fail (IS_VALID_ICON_POSITION (icon_pos), FALSE);
+
+  priv = entry->priv;
+  icon_info = priv->icons[icon_pos];
+
+  return (!icon_info || !icon_info->nonactivatable);
+}
+
+/**
+ * gtk_entry_get_icon_pixbuf:
+ * @entry: A #GtkEntry
+ * @icon_pos: Icon position
+ *
+ * Retrieves the image used for the icon.
+ *
+ * Unlike the other methods of setting and getting icon data, this
+ * method will work regardless of whether the icon was set using a
+ * #GdkPixbuf, a #GIcon, a stock item, or an icon name.
+ *
+ * Returns: (transfer none): A #GdkPixbuf, or %NULL if no icon is
+ *     set for this position.
+ *
+ * Since: 2.16
+ */
+GdkPixbuf *
+gtk_entry_get_icon_pixbuf (GtkEntry             *entry,
+                           GtkEntryIconPosition  icon_pos)
+{
+  GtkEntryPrivate *priv;
+  EntryIconInfo *icon_info;
+
+  g_return_val_if_fail (GTK_IS_ENTRY (entry), NULL);
+  g_return_val_if_fail (IS_VALID_ICON_POSITION (icon_pos), NULL);
+
+  priv = entry->priv;
+
+  icon_info = priv->icons[icon_pos];
+
+  if (!icon_info)
+    return NULL;
+
+  gtk_entry_ensure_pixbuf (entry, icon_pos);
+
+  return icon_info->pixbuf;
+}
+
+/**
+ * gtk_entry_get_icon_gicon:
+ * @entry: A #GtkEntry
+ * @icon_pos: Icon position
+ *
+ * Retrieves the #GIcon used for the icon, or %NULL if there is
+ * no icon or if the icon was set by some other method (e.g., by
+ * stock, pixbuf, or icon name).
+ *
+ * Returns: (transfer none): A #GIcon, or %NULL if no icon is set
+ *     or if the icon is not a #GIcon
+ *
+ * Since: 2.16
+ */
+GIcon *
+gtk_entry_get_icon_gicon (GtkEntry             *entry,
+                          GtkEntryIconPosition  icon_pos)
+{
+  GtkEntryPrivate *priv;
+  EntryIconInfo *icon_info;
+
+  g_return_val_if_fail (GTK_IS_ENTRY (entry), NULL);
+  g_return_val_if_fail (IS_VALID_ICON_POSITION (icon_pos), NULL);
+
+  priv = entry->priv;
+  icon_info = priv->icons[icon_pos];
+
+  if (!icon_info)
+    return NULL;
+
+  return icon_info->storage_type == GTK_IMAGE_GICON ? icon_info->gicon : NULL;
+}
+
+/**
+ * gtk_entry_get_icon_stock:
+ * @entry: A #GtkEntry
+ * @icon_pos: Icon position
+ *
+ * Retrieves the stock id used for the icon, or %NULL if there is
+ * no icon or if the icon was set by some other method (e.g., by
+ * pixbuf, icon name or gicon).
+ *
+ * Returns: A stock id, or %NULL if no icon is set or if the icon
+ *          wasn't set from a stock id
+ *
+ * Since: 2.16
+ */
+const gchar *
+gtk_entry_get_icon_stock (GtkEntry             *entry,
+                          GtkEntryIconPosition  icon_pos)
+{
+  GtkEntryPrivate *priv;
+  EntryIconInfo *icon_info;
+
+  g_return_val_if_fail (GTK_IS_ENTRY (entry), NULL);
+  g_return_val_if_fail (IS_VALID_ICON_POSITION (icon_pos), NULL);
+
+  priv = entry->priv;
+  icon_info = priv->icons[icon_pos];
+
+  if (!icon_info)
+    return NULL;
+
+  return icon_info->storage_type == GTK_IMAGE_STOCK ? icon_info->stock_id : NULL;
+}
+
+/**
+ * gtk_entry_get_icon_name:
+ * @entry: A #GtkEntry
+ * @icon_pos: Icon position
+ *
+ * Retrieves the icon name used for the icon, or %NULL if there is
+ * no icon or if the icon was set by some other method (e.g., by
+ * pixbuf, stock or gicon).
+ *
+ * Returns: An icon name, or %NULL if no icon is set or if the icon
+ *          wasn't set from an icon name
+ *
+ * Since: 2.16
+ */
+const gchar *
+gtk_entry_get_icon_name (GtkEntry             *entry,
+                         GtkEntryIconPosition  icon_pos)
+{
+  GtkEntryPrivate *priv;
+  EntryIconInfo *icon_info;
+
+  g_return_val_if_fail (GTK_IS_ENTRY (entry), NULL);
+  g_return_val_if_fail (IS_VALID_ICON_POSITION (icon_pos), NULL);
+
+  priv = entry->priv;
+  icon_info = priv->icons[icon_pos];
+
+  if (!icon_info)
+    return NULL;
+
+  return icon_info->storage_type == GTK_IMAGE_ICON_NAME ? icon_info->icon_name : NULL;
+}
+
+/**
+ * gtk_entry_set_icon_sensitive:
+ * @entry: A #GtkEntry
+ * @icon_pos: Icon position
+ * @sensitive: Specifies whether the icon should appear
+ *             sensitive or insensitive
+ *
+ * Sets the sensitivity for the specified icon.
+ *
+ * Since: 2.16
+ */
+void
+gtk_entry_set_icon_sensitive (GtkEntry             *entry,
+                              GtkEntryIconPosition  icon_pos,
+                              gboolean              sensitive)
+{
+  GtkEntryPrivate *priv;
+  EntryIconInfo *icon_info;
+
+  g_return_if_fail (GTK_IS_ENTRY (entry));
+  g_return_if_fail (IS_VALID_ICON_POSITION (icon_pos));
+
+  priv = entry->priv;
+
+  if ((icon_info = priv->icons[icon_pos]) == NULL)
+    icon_info = construct_icon_info (GTK_WIDGET (entry), icon_pos);
+
+  if (icon_info->insensitive != !sensitive)
+    {
+      icon_info->insensitive = !sensitive;
+
+      icon_info->pressed = FALSE;
+      icon_info->prelight = FALSE;
+
+      if (gtk_widget_get_realized (GTK_WIDGET (entry)))
+        update_cursors (GTK_WIDGET (entry));
+
+      gtk_widget_queue_draw (GTK_WIDGET (entry));
+
+      g_object_notify (G_OBJECT (entry),
+                       icon_pos == GTK_ENTRY_ICON_PRIMARY ? "primary-icon-sensitive" : "secondary-icon-sensitive");
+    }
+}
+
+/**
+ * gtk_entry_get_icon_sensitive:
+ * @entry: a #GtkEntry
+ * @icon_pos: Icon position
+ *
+ * Returns whether the icon appears sensitive or insensitive.
+ *
+ * Returns: %TRUE if the icon is sensitive.
+ *
+ * Since: 2.16
+ */
+gboolean
+gtk_entry_get_icon_sensitive (GtkEntry             *entry,
+                              GtkEntryIconPosition  icon_pos)
+{
+  GtkEntryPrivate *priv;
+  EntryIconInfo *icon_info;
+
+  g_return_val_if_fail (GTK_IS_ENTRY (entry), TRUE);
+  g_return_val_if_fail (IS_VALID_ICON_POSITION (icon_pos), TRUE);
+
+  priv = entry->priv;
+
+  icon_info = priv->icons[icon_pos];
+
+  return (!icon_info || !icon_info->insensitive);
+
+}
+
+/**
+ * gtk_entry_get_icon_storage_type:
+ * @entry: a #GtkEntry
+ * @icon_pos: Icon position
+ *
+ * Gets the type of representation being used by the icon
+ * to store image data. If the icon has no image data,
+ * the return value will be %GTK_IMAGE_EMPTY.
+ *
+ * Return value: image representation being used
+ *
+ * Since: 2.16
+ **/
+GtkImageType
+gtk_entry_get_icon_storage_type (GtkEntry             *entry,
+                                 GtkEntryIconPosition  icon_pos)
+{
+  GtkEntryPrivate *priv;
+  EntryIconInfo *icon_info;
+
+  g_return_val_if_fail (GTK_IS_ENTRY (entry), GTK_IMAGE_EMPTY);
+  g_return_val_if_fail (IS_VALID_ICON_POSITION (icon_pos), GTK_IMAGE_EMPTY);
+
+  priv = entry->priv;
+
+  icon_info = priv->icons[icon_pos];
+
+  if (!icon_info)
+    return GTK_IMAGE_EMPTY;
+
+  return icon_info->storage_type;
+}
+
+/**
+ * gtk_entry_get_icon_at_pos:
+ * @entry: a #GtkEntry
+ * @x: the x coordinate of the position to find
+ * @y: the y coordinate of the position to find
+ *
+ * Finds the icon at the given position and return its index.
+ * If @x, @y doesn't lie inside an icon, -1 is returned.
+ * This function is intended for use in a #GtkWidget::query-tooltip
+ * signal handler.
+ *
+ * Returns: the index of the icon at the given position, or -1
+ *
+ * Since: 2.16
+ */
+gint
+gtk_entry_get_icon_at_pos (GtkEntry *entry,
+                           gint      x,
+                           gint      y)
+{
+  GtkAllocation primary;
+  GtkAllocation secondary;
+  gint frame_x, frame_y;
+
+  g_return_val_if_fail (GTK_IS_ENTRY (entry), -1);
+
+  get_frame_size (entry, &frame_x, &frame_y, NULL, NULL);
+  x -= frame_x;
+  y -= frame_y;
+
+  get_icon_allocations (entry, &primary, &secondary);
+
+  if (primary.x <= x && x < primary.x + primary.width &&
+      primary.y <= y && y < primary.y + primary.height)
+    return GTK_ENTRY_ICON_PRIMARY;
+
+  if (secondary.x <= x && x < secondary.x + secondary.width &&
+      secondary.y <= y && y < secondary.y + secondary.height)
+    return GTK_ENTRY_ICON_SECONDARY;
+
+  return -1;
+}
+
+/**
+ * gtk_entry_set_icon_drag_source:
+ * @entry: a #GtkIconEntry
+ * @icon_pos: icon position
+ * @target_list: the targets (data formats) in which the data can be provided
+ * @actions: a bitmask of the allowed drag actions
+ *
+ * Sets up the icon at the given position so that GTK+ will start a drag
+ * operation when the user clicks and drags the icon.
+ *
+ * To handle the drag operation, you need to connect to the usual
+ * #GtkWidget::drag-data-get (or possibly #GtkWidget::drag-data-delete)
+ * signal, and use gtk_entry_get_current_icon_drag_source() in
+ * your signal handler to find out if the drag was started from
+ * an icon.
+ *
+ * By default, GTK+ uses the icon as the drag icon. You can use the 
+ * #GtkWidget::drag-begin signal to set a different icon. Note that you 
+ * have to use g_signal_connect_after() to ensure that your signal handler
+ * gets executed after the default handler.
+ *
+ * Since: 2.16
+ */
+void
+gtk_entry_set_icon_drag_source (GtkEntry             *entry,
+                                GtkEntryIconPosition  icon_pos,
+                                GtkTargetList        *target_list,
+                                GdkDragAction         actions)
+{
+  GtkEntryPrivate *priv;
+  EntryIconInfo *icon_info;
+
+  g_return_if_fail (GTK_IS_ENTRY (entry));
+  g_return_if_fail (IS_VALID_ICON_POSITION (icon_pos));
+
+  priv = entry->priv;
+
+  if ((icon_info = priv->icons[icon_pos]) == NULL)
+    icon_info = construct_icon_info (GTK_WIDGET (entry), icon_pos);
+
+  if (icon_info->target_list)
+    gtk_target_list_unref (icon_info->target_list);
+  icon_info->target_list = target_list;
+  if (icon_info->target_list)
+    gtk_target_list_ref (icon_info->target_list);
+
+  icon_info->actions = actions;
+}
+
+/**
+ * gtk_entry_get_current_icon_drag_source:
+ * @entry: a #GtkIconEntry
+ *
+ * Returns the index of the icon which is the source of the current
+ * DND operation, or -1.
+ *
+ * This function is meant to be used in a #GtkWidget::drag-data-get
+ * callback.
+ *
+ * Returns: index of the icon which is the source of the current
+ *          DND operation, or -1.
+ *
+ * Since: 2.16
+ */
+gint
+gtk_entry_get_current_icon_drag_source (GtkEntry *entry)
+{
+  GtkEntryPrivate *priv;
+  EntryIconInfo *icon_info = NULL;
+  gint i;
+
+  g_return_val_if_fail (GTK_IS_ENTRY (entry), -1);
+
+  priv = entry->priv;
+
+  for (i = 0; i < MAX_ICONS; i++)
+    {
+      if ((icon_info = priv->icons[i]))
+        {
+          if (icon_info->in_drag)
+            return i;
+        }
+    }
+
+  return -1;
+}
+
+/**
+ * gtk_entry_get_icon_area:
+ * @entry: A #GtkEntry
+ * @icon_pos: Icon position
+ * @icon_area: (out): Return location for the icon's area
+ *
+ * Gets the area where entry's icon at @icon_pos is drawn.
+ * This function is useful when drawing something to the
+ * entry in a draw callback.
+ *
+ * If the entry is not realized or has no icon at the given position,
+ * @icon_area is filled with zeros.
+ *
+ * See also gtk_entry_get_text_area()
+ *
+ * Since: 3.0
+ */
+void
+gtk_entry_get_icon_area (GtkEntry             *entry,
+                         GtkEntryIconPosition  icon_pos,
+                         GdkRectangle         *icon_area)
+{
+  GtkEntryPrivate *priv;
+  EntryIconInfo *icon_info;
+
+  g_return_if_fail (GTK_IS_ENTRY (entry));
+  g_return_if_fail (icon_area != NULL);
+
+  priv = entry->priv;
+
+  icon_info = priv->icons[icon_pos];
+
+  if (icon_info)
+    {
+      GtkAllocation primary;
+      GtkAllocation secondary;
+
+      get_icon_allocations (entry, &primary, &secondary);
+
+      if (icon_pos == GTK_ENTRY_ICON_PRIMARY)
+        *icon_area = primary;
+      else
+        *icon_area = secondary;
+    }
+  else
+    {
+      icon_area->x = 0;
+      icon_area->y = 0;
+      icon_area->width = 0;
+      icon_area->height = 0;
+    }
+}
+
+static void
+ensure_has_tooltip (GtkEntry *entry)
+{
+  GtkEntryPrivate *priv;
+  EntryIconInfo *icon_info;
+  int i;
+  gboolean has_tooltip = FALSE;
+
+  priv = entry->priv;
+
+  for (i = 0; i < MAX_ICONS; i++)
+    {
+      if ((icon_info = priv->icons[i]) != NULL)
+        {
+          if (icon_info->tooltip != NULL)
+            {
+              has_tooltip = TRUE;
+              break;
+            }
+        }
+    }
+
+  gtk_widget_set_has_tooltip (GTK_WIDGET (entry), has_tooltip);
+}
+
+/**
+ * gtk_entry_get_icon_tooltip_text:
+ * @entry: a #GtkEntry
+ * @icon_pos: the icon position
+ *
+ * Gets the contents of the tooltip on the icon at the specified 
+ * position in @entry.
+ * 
+ * Returns: the tooltip text, or %NULL. Free the returned string
+ *     with g_free() when done.
+ * 
+ * Since: 2.16
+ */
+gchar *
+gtk_entry_get_icon_tooltip_text (GtkEntry             *entry,
+                                 GtkEntryIconPosition  icon_pos)
+{
+  GtkEntryPrivate *priv;
+  EntryIconInfo *icon_info;
+  gchar *text = NULL;
+
+  g_return_val_if_fail (GTK_IS_ENTRY (entry), NULL);
+  g_return_val_if_fail (IS_VALID_ICON_POSITION (icon_pos), NULL);
+
+  priv = entry->priv;
+
+  icon_info = priv->icons[icon_pos];
+
+  if (!icon_info)
+    return NULL;
+  if (icon_info->tooltip && 
+      !pango_parse_markup (icon_info->tooltip, -1, 0, NULL, &text, NULL, NULL))
+    g_assert (NULL == text); /* text should still be NULL in case of markup errors */
+
+  return text;
+}
+
+/**
+ * gtk_entry_set_icon_tooltip_text:
+ * @entry: a #GtkEntry
+ * @icon_pos: the icon position
+ * @tooltip: (allow-none): the contents of the tooltip for the icon, or %NULL
+ *
+ * Sets @tooltip as the contents of the tooltip for the icon
+ * at the specified position.
+ *
+ * Use %NULL for @tooltip to remove an existing tooltip.
+ *
+ * See also gtk_widget_set_tooltip_text() and 
+ * gtk_entry_set_icon_tooltip_markup().
+ *
+ * Since: 2.16
+ */
+void
+gtk_entry_set_icon_tooltip_text (GtkEntry             *entry,
+                                 GtkEntryIconPosition  icon_pos,
+                                 const gchar          *tooltip)
+{
+  GtkEntryPrivate *priv;
+  EntryIconInfo *icon_info;
+
+  g_return_if_fail (GTK_IS_ENTRY (entry));
+  g_return_if_fail (IS_VALID_ICON_POSITION (icon_pos));
+
+  priv = entry->priv;
+
+  if ((icon_info = priv->icons[icon_pos]) == NULL)
+    icon_info = construct_icon_info (GTK_WIDGET (entry), icon_pos);
+
+  if (icon_info->tooltip)
+    g_free (icon_info->tooltip);
+
+  /* Treat an empty string as a NULL string,
+   * because an empty string would be useless for a tooltip:
+   */
+  if (tooltip && tooltip[0] == '\0')
+    tooltip = NULL;
+
+  icon_info->tooltip = tooltip ? g_markup_escape_text (tooltip, -1) : NULL;
+
+  ensure_has_tooltip (entry);
+}
+
+/**
+ * gtk_entry_get_icon_tooltip_markup:
+ * @entry: a #GtkEntry
+ * @icon_pos: the icon position
+ *
+ * Gets the contents of the tooltip on the icon at the specified 
+ * position in @entry.
+ * 
+ * Returns: the tooltip text, or %NULL. Free the returned string
+ *     with g_free() when done.
+ * 
+ * Since: 2.16
+ */
+gchar *
+gtk_entry_get_icon_tooltip_markup (GtkEntry             *entry,
+                                   GtkEntryIconPosition  icon_pos)
+{
+  GtkEntryPrivate *priv;
+  EntryIconInfo *icon_info;
+
+  g_return_val_if_fail (GTK_IS_ENTRY (entry), NULL);
+  g_return_val_if_fail (IS_VALID_ICON_POSITION (icon_pos), NULL);
+
+  priv = entry->priv;
+
+  icon_info = priv->icons[icon_pos];
+
+  if (!icon_info)
+    return NULL;
+  return g_strdup (icon_info->tooltip);
+}
+
+/**
+ * gtk_entry_set_icon_tooltip_markup:
+ * @entry: a #GtkEntry
+ * @icon_pos: the icon position
+ * @tooltip: (allow-none): the contents of the tooltip for the icon, or %NULL
+ *
+ * Sets @tooltip as the contents of the tooltip for the icon at
+ * the specified position. @tooltip is assumed to be marked up with
+ * the <link linkend="PangoMarkupFormat">Pango text markup language</link>.
+ *
+ * Use %NULL for @tooltip to remove an existing tooltip.
+ *
+ * See also gtk_widget_set_tooltip_markup() and 
+ * gtk_enty_set_icon_tooltip_text().
+ *
+ * Since: 2.16
+ */
+void
+gtk_entry_set_icon_tooltip_markup (GtkEntry             *entry,
+                                   GtkEntryIconPosition  icon_pos,
+                                   const gchar          *tooltip)
+{
+  GtkEntryPrivate *priv;
+  EntryIconInfo *icon_info;
+
+  g_return_if_fail (GTK_IS_ENTRY (entry));
+  g_return_if_fail (IS_VALID_ICON_POSITION (icon_pos));
+
+  priv = entry->priv;
+
+  if ((icon_info = priv->icons[icon_pos]) == NULL)
+    icon_info = construct_icon_info (GTK_WIDGET (entry), icon_pos);
+
+  if (icon_info->tooltip)
+    g_free (icon_info->tooltip);
+
+  /* Treat an empty string as a NULL string,
+   * because an empty string would be useless for a tooltip:
+   */
+  if (tooltip && tooltip[0] == '\0')
+    tooltip = NULL;
+
+  icon_info->tooltip = g_strdup (tooltip);
+
+  ensure_has_tooltip (entry);
+}
+
+static gboolean
+gtk_entry_query_tooltip (GtkWidget  *widget,
+                         gint        x,
+                         gint        y,
+                         gboolean    keyboard_tip,
+                         GtkTooltip *tooltip)
+{
+  GtkEntry *entry;
   GtkEntryPrivate *priv;
-  
-  g_return_val_if_fail (GTK_IS_ENTRY (entry), 0.0);
+  EntryIconInfo *icon_info;
+  gint icon_pos;
+
+  entry = GTK_ENTRY (widget);
+  priv = entry->priv;
 
-  priv = GTK_ENTRY_GET_PRIVATE (entry);
+  if (!keyboard_tip)
+    {
+      icon_pos = gtk_entry_get_icon_at_pos (entry, x, y);
+      if (icon_pos != -1)
+        {
+          if ((icon_info = priv->icons[icon_pos]) != NULL)
+            {
+              if (icon_info->tooltip)
+                {
+                  gtk_tooltip_set_markup (tooltip, icon_info->tooltip);
+                  return TRUE;
+                }
+
+              return FALSE;
+            }
+        }
+    }
 
-  return priv->xalign;
+  return GTK_WIDGET_CLASS (gtk_entry_parent_class)->query_tooltip (widget,
+                                                                   x, y,
+                                                                   keyboard_tip,
+                                                                   tooltip);
 }
 
+
 /* Quick hack of a popup menu
  */
 static void
@@ -5393,7 +8601,10 @@ static void
 popup_menu_detach (GtkWidget *attach_widget,
                   GtkMenu   *menu)
 {
-  GTK_ENTRY (attach_widget)->popup_menu = NULL;
+  GtkEntry *entry_attach = GTK_ENTRY (attach_widget);
+  GtkEntryPrivate *priv_attach = entry_attach->priv;
+
+  priv_attach->popup_menu = NULL;
 }
 
 static void
@@ -5404,6 +8615,7 @@ popup_position_func (GtkMenu   *menu,
                      gpointer  user_data)
 {
   GtkEntry *entry = GTK_ENTRY (user_data);
+  GtkEntryPrivate *priv = entry->priv;
   GtkWidget *widget = GTK_WIDGET (entry);
   GdkScreen *screen;
   GtkRequisition menu_req;
@@ -5411,23 +8623,24 @@ popup_position_func (GtkMenu   *menu,
   GtkBorder inner_border;
   gint monitor_num, strong_x, height;
  
-  g_return_if_fail (GTK_WIDGET_REALIZED (entry));
+  g_return_if_fail (gtk_widget_get_realized (widget));
 
-  gdk_window_get_origin (entry->text_area, x, y);
+  gdk_window_get_origin (priv->text_area, x, y);
 
   screen = gtk_widget_get_screen (widget);
-  monitor_num = gdk_screen_get_monitor_at_window (screen, entry->text_area);
+  monitor_num = gdk_screen_get_monitor_at_window (screen, priv->text_area);
   if (monitor_num < 0)
     monitor_num = 0;
   gtk_menu_set_monitor (menu, monitor_num);
 
   gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
-  gtk_widget_size_request (entry->popup_menu, &menu_req);
-  gdk_drawable_get_size (entry->text_area, NULL, &height);
+  gtk_widget_get_preferred_size (priv->popup_menu,
+                                 &menu_req, NULL);
+  height = gdk_window_get_height (priv->text_area);
   gtk_entry_get_cursor_locations (entry, CURSOR_STANDARD, &strong_x, NULL);
   _gtk_entry_effective_inner_border (entry, &inner_border);
 
-  *x += inner_border.left + strong_x - entry->scroll_offset;
+  *x += inner_border.left + strong_x - priv->scroll_offset;
   if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
     *x -= menu_req.width;
 
@@ -5448,8 +8661,9 @@ unichar_chosen_func (const char *text,
                      gpointer    data)
 {
   GtkEntry *entry = GTK_ENTRY (data);
+  GtkEntryPrivate *priv = entry->priv;
 
-  if (entry->editable)
+  if (priv->editable)
     gtk_entry_enter_text (entry, text);
 }
 
@@ -5467,9 +8681,11 @@ popup_targets_received (GtkClipboard     *clipboard,
 {
   PopupInfo *info = user_data;
   GtkEntry *entry = info->entry;
-  
-  if (GTK_WIDGET_REALIZED (entry))
+  GtkEntryPrivate *info_entry_priv = entry->priv;
+
+  if (gtk_widget_get_realized (GTK_WIDGET (entry)))
     {
+      DisplayMode mode;
       gboolean clipboard_contains_text;
       GtkWidget *menuitem;
       GtkWidget *submenu;
@@ -5477,38 +8693,43 @@ popup_targets_received (GtkClipboard     *clipboard,
       gboolean show_unicode_menu;
       
       clipboard_contains_text = gtk_selection_data_targets_include_text (data);
-      if (entry->popup_menu)
-       gtk_widget_destroy (entry->popup_menu);
-      
-      entry->popup_menu = gtk_menu_new ();
-      
-      gtk_menu_attach_to_widget (GTK_MENU (entry->popup_menu),
+      if (info_entry_priv->popup_menu)
+       gtk_widget_destroy (info_entry_priv->popup_menu);
+
+      info_entry_priv->popup_menu = gtk_menu_new ();
+
+      gtk_menu_attach_to_widget (GTK_MENU (info_entry_priv->popup_menu),
                                 GTK_WIDGET (entry),
                                 popup_menu_detach);
       
-      append_action_signal (entry, entry->popup_menu, GTK_STOCK_CUT, "cut-clipboard",
-                           entry->editable && entry->visible && entry->current_pos != entry->selection_bound);
-      append_action_signal (entry, entry->popup_menu, GTK_STOCK_COPY, "copy-clipboard",
-                           entry->visible && entry->current_pos != entry->selection_bound);
-      append_action_signal (entry, entry->popup_menu, GTK_STOCK_PASTE, "paste-clipboard",
-                           entry->editable && clipboard_contains_text);
-      
+      mode = gtk_entry_get_display_mode (entry);
+      append_action_signal (entry, info_entry_priv->popup_menu, GTK_STOCK_CUT, "cut-clipboard",
+                            info_entry_priv->editable && mode == DISPLAY_NORMAL &&
+                            info_entry_priv->current_pos != info_entry_priv->selection_bound);
+
+      append_action_signal (entry, info_entry_priv->popup_menu, GTK_STOCK_COPY, "copy-clipboard",
+                            mode == DISPLAY_NORMAL &&
+                            info_entry_priv->current_pos != info_entry_priv->selection_bound);
+
+      append_action_signal (entry, info_entry_priv->popup_menu, GTK_STOCK_PASTE, "paste-clipboard",
+                            info_entry_priv->editable && clipboard_contains_text);
+
       menuitem = gtk_image_menu_item_new_from_stock (GTK_STOCK_DELETE, NULL);
-      gtk_widget_set_sensitive (menuitem, entry->editable && entry->current_pos != entry->selection_bound);
+      gtk_widget_set_sensitive (menuitem, info_entry_priv->editable && info_entry_priv->current_pos != info_entry_priv->selection_bound);
       g_signal_connect_swapped (menuitem, "activate",
                                G_CALLBACK (gtk_entry_delete_cb), entry);
       gtk_widget_show (menuitem);
-      gtk_menu_shell_append (GTK_MENU_SHELL (entry->popup_menu), menuitem);
+      gtk_menu_shell_append (GTK_MENU_SHELL (info_entry_priv->popup_menu), menuitem);
 
       menuitem = gtk_separator_menu_item_new ();
       gtk_widget_show (menuitem);
-      gtk_menu_shell_append (GTK_MENU_SHELL (entry->popup_menu), menuitem);
+      gtk_menu_shell_append (GTK_MENU_SHELL (info_entry_priv->popup_menu), menuitem);
       
       menuitem = gtk_image_menu_item_new_from_stock (GTK_STOCK_SELECT_ALL, NULL);
       g_signal_connect_swapped (menuitem, "activate",
                                G_CALLBACK (gtk_entry_select_all), entry);
       gtk_widget_show (menuitem);
-      gtk_menu_shell_append (GTK_MENU_SHELL (entry->popup_menu), menuitem);
+      gtk_menu_shell_append (GTK_MENU_SHELL (info_entry_priv->popup_menu), menuitem);
       
       g_object_get (gtk_widget_get_settings (GTK_WIDGET (entry)),
                     "gtk-show-input-method-menu", &show_input_method_menu,
@@ -5519,33 +8740,33 @@ popup_targets_received (GtkClipboard     *clipboard,
         {
           menuitem = gtk_separator_menu_item_new ();
           gtk_widget_show (menuitem);
-          gtk_menu_shell_append (GTK_MENU_SHELL (entry->popup_menu), menuitem);
+          gtk_menu_shell_append (GTK_MENU_SHELL (info_entry_priv->popup_menu), menuitem);
         }
       
       if (show_input_method_menu)
         {
           menuitem = gtk_menu_item_new_with_mnemonic (_("Input _Methods"));
-          gtk_widget_set_sensitive (menuitem, entry->editable);      
+          gtk_widget_set_sensitive (menuitem, info_entry_priv->editable);
           gtk_widget_show (menuitem);
           submenu = gtk_menu_new ();
           gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), submenu);
-          
-          gtk_menu_shell_append (GTK_MENU_SHELL (entry->popup_menu), menuitem);
-      
-          gtk_im_multicontext_append_menuitems (GTK_IM_MULTICONTEXT (entry->im_context),
+
+          gtk_menu_shell_append (GTK_MENU_SHELL (info_entry_priv->popup_menu), menuitem);
+
+          gtk_im_multicontext_append_menuitems (GTK_IM_MULTICONTEXT (info_entry_priv->im_context),
                                                 GTK_MENU_SHELL (submenu));
         }
       
       if (show_unicode_menu)
         {
           menuitem = gtk_menu_item_new_with_mnemonic (_("_Insert Unicode Control Character"));
-          gtk_widget_set_sensitive (menuitem, entry->editable);      
+          gtk_widget_set_sensitive (menuitem, info_entry_priv->editable);
           gtk_widget_show (menuitem);
           
           submenu = gtk_menu_new ();
           gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), submenu);
-          gtk_menu_shell_append (GTK_MENU_SHELL (entry->popup_menu), menuitem);      
-          
+          gtk_menu_shell_append (GTK_MENU_SHELL (info_entry_priv->popup_menu), menuitem);
+
           _gtk_text_util_append_special_char_menuitems (GTK_MENU_SHELL (submenu),
                                                         unichar_chosen_func,
                                                         entry);
@@ -5554,19 +8775,19 @@ popup_targets_received (GtkClipboard     *clipboard,
       g_signal_emit (entry,
                     signals[POPULATE_POPUP],
                     0,
-                    entry->popup_menu);
-  
+                    info_entry_priv->popup_menu);
+
 
       if (info->button)
-       gtk_menu_popup (GTK_MENU (entry->popup_menu), NULL, NULL,
+       gtk_menu_popup (GTK_MENU (info_entry_priv->popup_menu), NULL, NULL,
                        NULL, NULL,
                        info->button, info->time);
       else
        {
-         gtk_menu_popup (GTK_MENU (entry->popup_menu), NULL, NULL,
+         gtk_menu_popup (GTK_MENU (info_entry_priv->popup_menu), NULL, NULL,
                          popup_position_func, entry,
                          info->button, info->time);
-         gtk_menu_shell_select_first (GTK_MENU_SHELL (entry->popup_menu), FALSE);
+         gtk_menu_shell_select_first (GTK_MENU_SHELL (info_entry_priv->popup_menu), FALSE);
        }
     }
 
@@ -5610,14 +8831,71 @@ gtk_entry_popup_menu (GtkWidget *widget)
   return TRUE;
 }
 
+static void
+gtk_entry_drag_begin (GtkWidget      *widget,
+                      GdkDragContext *context)
+{
+  GtkEntry *entry = GTK_ENTRY (widget);
+  GtkEntryPrivate *priv = entry->priv;
+  gint i;
+
+  for (i = 0; i < MAX_ICONS; i++)
+    {
+      EntryIconInfo *icon_info = priv->icons[i];
+      
+      if (icon_info != NULL)
+        {
+          if (icon_info->in_drag) 
+            {
+              switch (icon_info->storage_type)
+                {
+                case GTK_IMAGE_STOCK:
+                  gtk_drag_set_icon_stock (context, icon_info->stock_id, -2, -2);
+                  break;
+
+                case GTK_IMAGE_ICON_NAME:
+                  gtk_drag_set_icon_name (context, icon_info->icon_name, -2, -2);
+                  break;
+
+                  /* FIXME: No GIcon support for dnd icons */
+                case GTK_IMAGE_GICON:
+                case GTK_IMAGE_PIXBUF:
+                  gtk_drag_set_icon_pixbuf (context, icon_info->pixbuf, -2, -2);
+                  break;
+                default:
+                  g_assert_not_reached ();
+                }
+            }
+        }
+    }
+}
+
+static void
+gtk_entry_drag_end (GtkWidget      *widget,
+                    GdkDragContext *context)
+{
+  GtkEntry *entry = GTK_ENTRY (widget);
+  GtkEntryPrivate *priv = entry->priv;
+  gint i;
+
+  for (i = 0; i < MAX_ICONS; i++)
+    {
+      EntryIconInfo *icon_info = priv->icons[i];
+
+      if (icon_info != NULL)
+        icon_info->in_drag = 0;
+    }
+}
+
 static void
 gtk_entry_drag_leave (GtkWidget        *widget,
                      GdkDragContext   *context,
                      guint             time)
 {
   GtkEntry *entry = GTK_ENTRY (widget);
+  GtkEntryPrivate *priv = entry->priv;
 
-  entry->dnd_position = -1;
+  priv->dnd_position = -1;
   gtk_widget_queue_draw (widget);
 }
 
@@ -5629,9 +8907,10 @@ gtk_entry_drag_drop  (GtkWidget        *widget,
                      guint             time)
 {
   GtkEntry *entry = GTK_ENTRY (widget);
+  GtkEntryPrivate *priv = entry->priv;
   GdkAtom target = GDK_NONE;
-  
-  if (entry->editable)
+
+  if (priv->editable)
     target = gtk_drag_dest_find_target (widget, context, NULL);
 
   if (target != GDK_NONE)
@@ -5650,22 +8929,27 @@ gtk_entry_drag_motion (GtkWidget        *widget,
                       guint             time)
 {
   GtkEntry *entry = GTK_ENTRY (widget);
+  GtkEntryPrivate *priv = entry->priv;
+  GtkStyleContext *style_context;
   GtkWidget *source_widget;
   GdkDragAction suggested_action;
   gint new_position, old_position;
   gint sel1, sel2;
-  
-  x -= widget->style->xthickness;
-  y -= widget->style->ythickness;
-  
-  old_position = entry->dnd_position;
-  new_position = gtk_entry_find_position (entry, x + entry->scroll_offset);
+  GtkBorder padding;
+
+  style_context = gtk_widget_get_style_context (widget);
+  gtk_style_context_get_padding (style_context, 0, &padding);
+  x -= padding.left;
+  y -= padding.top;
 
-  if (entry->editable &&
+  old_position = priv->dnd_position;
+  new_position = gtk_entry_find_position (entry, x + priv->scroll_offset);
+
+  if (priv->editable &&
       gtk_drag_dest_find_target (widget, context, NULL) != GDK_NONE)
     {
       source_widget = gtk_drag_get_source_widget (context);
-      suggested_action = context->suggested_action;
+      suggested_action = gdk_drag_context_get_suggested_action (context);
 
       if (!gtk_editable_get_selection_bounds (GTK_EDITABLE (entry), &sel1, &sel2) ||
           new_position < sel1 || new_position > sel2)
@@ -5675,30 +8959,30 @@ gtk_entry_drag_motion (GtkWidget        *widget,
              /* Default to MOVE, unless the user has
               * pressed ctrl or alt to affect available actions
               */
-             if ((context->actions & GDK_ACTION_MOVE) != 0)
+             if ((gdk_drag_context_get_actions (context) & GDK_ACTION_MOVE) != 0)
                suggested_action = GDK_ACTION_MOVE;
            }
-              
-          entry->dnd_position = new_position;
+
+          priv->dnd_position = new_position;
         }
       else
         {
           if (source_widget == widget)
            suggested_action = 0;       /* Can't drop in selection where drag started */
-          
-          entry->dnd_position = -1;
+
+          priv->dnd_position = -1;
         }
     }
   else
     {
       /* Entry not editable, or no text */
       suggested_action = 0;
-      entry->dnd_position = -1;
+      priv->dnd_position = -1;
     }
   
   gdk_drag_status (context, suggested_action, time);
-  
-  if (entry->dnd_position != old_position)
+
+  if (priv->dnd_position != old_position)
     gtk_widget_queue_draw (widget);
 
   return TRUE;
@@ -5714,24 +8998,29 @@ gtk_entry_drag_data_received (GtkWidget        *widget,
                              guint             time)
 {
   GtkEntry *entry = GTK_ENTRY (widget);
+  GtkEntryPrivate *priv = entry->priv;
   GtkEditable *editable = GTK_EDITABLE (widget);
+  GtkStyleContext *style_context;
+  GtkBorder padding;
   gchar *str;
 
   str = (gchar *) gtk_selection_data_get_text (selection_data);
 
-  x -= widget->style->xthickness;
-  y -= widget->style->ythickness;
+  style_context = gtk_widget_get_style_context (widget);
+  gtk_style_context_get_padding (style_context, 0, &padding);
+  x -= padding.left;
+  y -= padding.top;
 
-  if (str && entry->editable)
+  if (str && priv->editable)
     {
       gint new_position;
       gint sel1, sel2;
       gint length = -1;
 
-      if (entry->truncate_multiline)
+      if (priv->truncate_multiline)
         length = truncate_multiline (str);
 
-      new_position = gtk_entry_find_position (entry, x + entry->scroll_offset);
+      new_position = gtk_entry_find_position (entry, x + priv->scroll_offset);
 
       if (!gtk_editable_get_selection_bounds (editable, &sel1, &sel2) ||
          new_position < sel1 || new_position > sel2)
@@ -5749,7 +9038,7 @@ gtk_entry_drag_data_received (GtkWidget        *widget,
           end_change (entry);
        }
       
-      gtk_drag_finish (context, TRUE, context->action == GDK_ACTION_MOVE, time);
+      gtk_drag_finish (context, TRUE, gdk_drag_context_get_selected_action (context) == GDK_ACTION_MOVE, time);
     }
   else
     {
@@ -5767,13 +9056,27 @@ gtk_entry_drag_data_get (GtkWidget        *widget,
                         guint             info,
                         guint             time)
 {
+  GtkEntry *entry = GTK_ENTRY (widget);
+  GtkEntryPrivate *priv = entry->priv;
+  GtkEditable *editable = GTK_EDITABLE (widget);
   gint sel_start, sel_end;
+  gint i;
+
+  /* If there is an icon drag going on, exit early. */
+  for (i = 0; i < MAX_ICONS; i++)
+    {
+      EntryIconInfo *icon_info = priv->icons[i];
+
+      if (icon_info != NULL)
+        {
+          if (icon_info->in_drag)
+            return;
+        }
+    }
 
-  GtkEditable *editable = GTK_EDITABLE (widget);
-  
   if (gtk_editable_get_selection_bounds (editable, &sel_start, &sel_end))
     {
-      gchar *str = gtk_entry_get_public_chars (GTK_ENTRY (widget), sel_start, sel_end);
+      gchar *str = gtk_entry_get_display_text (GTK_ENTRY (widget), sel_start, sel_end);
 
       gtk_selection_data_set_text (selection_data, str, -1);
       
@@ -5786,11 +9089,25 @@ static void
 gtk_entry_drag_data_delete (GtkWidget      *widget,
                            GdkDragContext *context)
 {
+  GtkEntry *entry = GTK_ENTRY (widget);
+  GtkEntryPrivate *priv = entry->priv;
+  GtkEditable *editable = GTK_EDITABLE (widget);
   gint sel_start, sel_end;
+  gint i;
 
-  GtkEditable *editable = GTK_EDITABLE (widget);
-  
-  if (GTK_ENTRY (widget)->editable &&
+  /* If there is an icon drag going on, exit early. */
+  for (i = 0; i < MAX_ICONS; i++)
+    {
+      EntryIconInfo *icon_info = priv->icons[i];
+
+      if (icon_info != NULL)
+        {
+          if (icon_info->in_drag)
+            return;
+        }
+    }
+
+  if (priv->editable &&
       gtk_editable_get_selection_bounds (editable, &sel_start, &sel_end))
     gtk_editable_delete_text (editable, sel_start, sel_end);
 }
@@ -5809,9 +9126,11 @@ gtk_entry_drag_data_delete (GtkWidget      *widget,
 static gboolean
 cursor_blinks (GtkEntry *entry)
 {
-  if (GTK_WIDGET_HAS_FOCUS (entry) &&
-      entry->editable &&
-      entry->selection_bound == entry->current_pos)
+  GtkEntryPrivate *priv = entry->priv;
+
+  if (gtk_widget_has_focus (GTK_WIDGET (entry)) &&
+      priv->editable &&
+      priv->selection_bound == priv->current_pos)
     {
       GtkSettings *settings;
       gboolean blink;
@@ -5850,24 +9169,32 @@ get_cursor_blink_timeout (GtkEntry *entry)
 static void
 show_cursor (GtkEntry *entry)
 {
-  if (!entry->cursor_visible)
+  GtkEntryPrivate *priv = entry->priv;
+  GtkWidget *widget;
+
+  if (!priv->cursor_visible)
     {
-      entry->cursor_visible = TRUE;
+      priv->cursor_visible = TRUE;
 
-      if (GTK_WIDGET_HAS_FOCUS (entry) && entry->selection_bound == entry->current_pos)
-       gtk_widget_queue_draw (GTK_WIDGET (entry));
+      widget = GTK_WIDGET (entry);
+      if (gtk_widget_has_focus (widget) && priv->selection_bound == priv->current_pos)
+       gtk_widget_queue_draw (widget);
     }
 }
 
 static void
 hide_cursor (GtkEntry *entry)
 {
-  if (entry->cursor_visible)
+  GtkEntryPrivate *priv = entry->priv;
+  GtkWidget *widget;
+
+  if (priv->cursor_visible)
     {
-      entry->cursor_visible = FALSE;
+      priv->cursor_visible = FALSE;
 
-      if (GTK_WIDGET_HAS_FOCUS (entry) && entry->selection_bound == entry->current_pos)
-       gtk_widget_queue_draw (GTK_WIDGET (entry));
+      widget = GTK_WIDGET (entry);
+      if (gtk_widget_has_focus (widget) && priv->selection_bound == priv->current_pos)
+       gtk_widget_queue_draw (widget);
     }
 }
 
@@ -5882,9 +9209,9 @@ blink_cb (gpointer data)
   gint blink_timeout;
 
   entry = GTK_ENTRY (data);
-  priv = GTK_ENTRY_GET_PRIVATE (entry);
+  priv = entry->priv;
  
-  if (!GTK_WIDGET_HAS_FOCUS (entry))
+  if (!gtk_widget_has_focus (GTK_WIDGET (entry)))
     {
       g_warning ("GtkEntry - did not receive focus-out-event. If you\n"
                 "connect a handler to this signal, it must return\n"
@@ -5895,7 +9222,7 @@ blink_cb (gpointer data)
       return FALSE;
     }
   
-  g_assert (entry->selection_bound == entry->current_pos);
+  g_assert (priv->selection_bound == priv->current_pos);
   
   blink_timeout = get_cursor_blink_timeout (entry);
   if (priv->blink_time > 1000 * blink_timeout && 
@@ -5903,12 +9230,12 @@ blink_cb (gpointer data)
     {
       /* we've blinked enough without the user doing anything, stop blinking */
       show_cursor (entry);
-      entry->blink_timeout = 0;
+      priv->blink_timeout = 0;
     } 
-  else if (entry->cursor_visible)
+  else if (priv->cursor_visible)
     {
       hide_cursor (entry);
-      entry->blink_timeout = gdk_threads_add_timeout (get_cursor_time (entry) * CURSOR_OFF_MULTIPLIER / CURSOR_DIVIDER,
+      priv->blink_timeout = gdk_threads_add_timeout (get_cursor_time (entry) * CURSOR_OFF_MULTIPLIER / CURSOR_DIVIDER,
                                            blink_cb,
                                            entry);
     }
@@ -5916,7 +9243,7 @@ blink_cb (gpointer data)
     {
       show_cursor (entry);
       priv->blink_time += get_cursor_time (entry);
-      entry->blink_timeout = gdk_threads_add_timeout (get_cursor_time (entry) * CURSOR_ON_MULTIPLIER / CURSOR_DIVIDER,
+      priv->blink_timeout = gdk_threads_add_timeout (get_cursor_time (entry) * CURSOR_ON_MULTIPLIER / CURSOR_DIVIDER,
                                            blink_cb,
                                            entry);
     }
@@ -5928,44 +9255,43 @@ blink_cb (gpointer data)
 static void
 gtk_entry_check_cursor_blink (GtkEntry *entry)
 {
-  GtkEntryPrivate *priv; 
-  
-  priv = GTK_ENTRY_GET_PRIVATE (entry);
+  GtkEntryPrivate *priv = entry->priv;
 
   if (cursor_blinks (entry))
     {
-      if (!entry->blink_timeout)
+      if (!priv->blink_timeout)
        {
          show_cursor (entry);
-         entry->blink_timeout = gdk_threads_add_timeout (get_cursor_time (entry) * CURSOR_ON_MULTIPLIER / CURSOR_DIVIDER,
+         priv->blink_timeout = gdk_threads_add_timeout (get_cursor_time (entry) * CURSOR_ON_MULTIPLIER / CURSOR_DIVIDER,
                                                blink_cb,
                                                entry);
        }
     }
   else
     {
-      if (entry->blink_timeout)  
-       { 
-         g_source_remove (entry->blink_timeout);
-         entry->blink_timeout = 0;
+      if (priv->blink_timeout)
+       {
+         g_source_remove (priv->blink_timeout);
+         priv->blink_timeout = 0;
        }
-      
-      entry->cursor_visible = TRUE;
+
+      priv->cursor_visible = TRUE;
     }
-  
 }
 
 static void
 gtk_entry_pend_cursor_blink (GtkEntry *entry)
 {
+  GtkEntryPrivate *priv = entry->priv;
+
   if (cursor_blinks (entry))
     {
-      if (entry->blink_timeout != 0)
-       g_source_remove (entry->blink_timeout);
-      
-      entry->blink_timeout = gdk_threads_add_timeout (get_cursor_time (entry) * CURSOR_PEND_MULTIPLIER / CURSOR_DIVIDER,
-                                           blink_cb,
-                                           entry);
+      if (priv->blink_timeout != 0)
+       g_source_remove (priv->blink_timeout);
+
+      priv->blink_timeout = gdk_threads_add_timeout (get_cursor_time (entry) * CURSOR_PEND_MULTIPLIER / CURSOR_DIVIDER,
+                                                     blink_cb,
+                                                     entry);
       show_cursor (entry);
     }
 }
@@ -5973,10 +9299,8 @@ gtk_entry_pend_cursor_blink (GtkEntry *entry)
 static void
 gtk_entry_reset_blink_time (GtkEntry *entry)
 {
-  GtkEntryPrivate *priv; 
-  
-  priv = GTK_ENTRY_GET_PRIVATE (entry);
-  
+  GtkEntryPrivate *priv = entry->priv;
+
   priv->blink_time = 0;
 }
 
@@ -5986,6 +9310,7 @@ static gint
 gtk_entry_completion_timeout (gpointer data)
 {
   GtkEntryCompletion *completion = GTK_ENTRY_COMPLETION (data);
+  GtkEntryPrivate *completion_entry_priv = GTK_ENTRY (completion->priv->entry)->priv;
 
   completion->priv->completion_timeout = 0;
 
@@ -6012,15 +9337,15 @@ gtk_entry_completion_timeout (gpointer data)
       g_object_get (completion, "popup-single-match", &popup_single, NULL);
       if ((matches > (popup_single ? 0: 1)) || actions > 0)
        { 
-         if (GTK_WIDGET_VISIBLE (completion->priv->popup_window))
+         if (gtk_widget_get_visible (completion->priv->popup_window))
            _gtk_entry_completion_resize_popup (completion);
           else
-           _gtk_entry_completion_popup (completion);
+           _gtk_entry_completion_popup (completion, completion_entry_priv->completion_device);
        }
       else 
        _gtk_entry_completion_popdown (completion);
     }
-  else if (GTK_WIDGET_VISIBLE (completion->priv->popup_window))
+  else if (gtk_widget_get_visible (completion->priv->popup_window))
     _gtk_entry_completion_popdown (completion);
 
   return FALSE;
@@ -6029,16 +9354,16 @@ gtk_entry_completion_timeout (gpointer data)
 static inline gboolean
 keyval_is_cursor_move (guint keyval)
 {
-  if (keyval == GDK_Up || keyval == GDK_KP_Up)
+  if (keyval == GDK_KEY_Up || keyval == GDK_KEY_KP_Up)
     return TRUE;
 
-  if (keyval == GDK_Down || keyval == GDK_KP_Down)
+  if (keyval == GDK_KEY_Down || keyval == GDK_KEY_KP_Down)
     return TRUE;
 
-  if (keyval == GDK_Page_Up)
+  if (keyval == GDK_KEY_Page_Up)
     return TRUE;
 
-  if (keyval == GDK_Page_Down)
+  if (keyval == GDK_KEY_Page_Down)
     return TRUE;
 
   return FALSE;
@@ -6052,7 +9377,7 @@ gtk_entry_completion_key_press (GtkWidget   *widget,
   gint matches, actions = 0;
   GtkEntryCompletion *completion = GTK_ENTRY_COMPLETION (user_data);
 
-  if (!GTK_WIDGET_MAPPED (completion->priv->popup_window))
+  if (!gtk_widget_get_mapped (completion->priv->popup_window))
     return FALSE;
 
   matches = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (completion->priv->filter_model), NULL);
@@ -6064,21 +9389,21 @@ gtk_entry_completion_key_press (GtkWidget   *widget,
     {
       GtkTreePath *path = NULL;
       
-      if (event->keyval == GDK_Up || event->keyval == GDK_KP_Up)
+      if (event->keyval == GDK_KEY_Up || event->keyval == GDK_KEY_KP_Up)
         {
          if (completion->priv->current_selected < 0)
            completion->priv->current_selected = matches + actions - 1;
          else
            completion->priv->current_selected--;
         }
-      else if (event->keyval == GDK_Down || event->keyval == GDK_KP_Down)
+      else if (event->keyval == GDK_KEY_Down || event->keyval == GDK_KEY_KP_Down)
         {
           if (completion->priv->current_selected < matches + actions - 1)
            completion->priv->current_selected++;
          else
             completion->priv->current_selected = -1;
         }
-      else if (event->keyval == GDK_Page_Up)
+      else if (event->keyval == GDK_KEY_Page_Up)
        {
          if (completion->priv->current_selected < 0)
            completion->priv->current_selected = matches + actions - 1;
@@ -6097,7 +9422,7 @@ gtk_entry_completion_key_press (GtkWidget   *widget,
                completion->priv->current_selected = matches - 1;
            }
        }
-      else if (event->keyval == GDK_Page_Down)
+      else if (event->keyval == GDK_KEY_Page_Down)
        {
          if (completion->priv->current_selected < 0)
            completion->priv->current_selected = 0;
@@ -6144,6 +9469,7 @@ gtk_entry_completion_key_press (GtkWidget   *widget,
             {
 
               GtkTreeIter iter;
+              GtkTreeIter child_iter;
               GtkTreeModel *model = NULL;
               GtkTreeSelection *sel;
               gboolean entry_set;
@@ -6151,12 +9477,15 @@ gtk_entry_completion_key_press (GtkWidget   *widget,
               sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (completion->priv->tree_view));
               if (!gtk_tree_selection_get_selected (sel, &model, &iter))
                 return FALSE;
+
+              gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER (model), &child_iter, &iter);
+              model = gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (model));
               
               if (completion->priv->completion_prefix == NULL)
                 completion->priv->completion_prefix = g_strdup (gtk_entry_get_text (GTK_ENTRY (completion->priv->entry)));
 
               g_signal_emit_by_name (completion, "cursor-on-match", model,
-                                     &iter, &entry_set);
+                                     &child_iter, &entry_set);
             }
         }
       else if (completion->priv->current_selected - matches >= 0)
@@ -6180,11 +9509,11 @@ gtk_entry_completion_key_press (GtkWidget   *widget,
 
       return TRUE;
     }
-  else if (event->keyval == GDK_Escape ||
-           event->keyval == GDK_Left ||
-           event->keyval == GDK_KP_Left ||
-           event->keyval == GDK_Right ||
-           event->keyval == GDK_KP_Right) 
+  else if (event->keyval == GDK_KEY_Escape ||
+           event->keyval == GDK_KEY_Left ||
+           event->keyval == GDK_KEY_KP_Left ||
+           event->keyval == GDK_KEY_Right ||
+           event->keyval == GDK_KEY_KP_Right) 
     {
       gboolean retval = TRUE;
 
@@ -6199,7 +9528,7 @@ gtk_entry_completion_key_press (GtkWidget   *widget,
       else if (completion->priv->inline_selection)
         {
           /* Escape rejects the tentative completion */
-          if (event->keyval == GDK_Escape)
+          if (event->keyval == GDK_KEY_Escape)
             {
               if (completion->priv->completion_prefix)
                 gtk_entry_set_text (GTK_ENTRY (completion->priv->entry), 
@@ -6210,9 +9539,9 @@ gtk_entry_completion_key_press (GtkWidget   *widget,
 
           /* Move the cursor to the end for Right/Esc, to the
              beginning for Left */
-          if (event->keyval == GDK_Right ||
-              event->keyval == GDK_KP_Right ||
-              event->keyval == GDK_Escape)
+          if (event->keyval == GDK_KEY_Right ||
+              event->keyval == GDK_KEY_KP_Right ||
+              event->keyval == GDK_KEY_Escape)
             gtk_editable_set_position (GTK_EDITABLE (widget), -1);
           else
             gtk_editable_set_position (GTK_EDITABLE (widget), 0);
@@ -6227,11 +9556,11 @@ keypress_completion_out:
 
       return retval;
     }
-  else if (event->keyval == GDK_Tab || 
-          event->keyval == GDK_KP_Tab ||
-          event->keyval == GDK_ISO_Left_Tab) 
+  else if (event->keyval == GDK_KEY_Tab || 
+          event->keyval == GDK_KEY_KP_Tab ||
+          event->keyval == GDK_KEY_ISO_Left_Tab) 
     {
-      GtkDirectionType dir = event->keyval == GDK_ISO_Left_Tab ? 
+      GtkDirectionType dir = event->keyval == GDK_KEY_ISO_Left_Tab ? 
        GTK_DIR_TAB_BACKWARD : GTK_DIR_TAB_FORWARD;
       
       _gtk_entry_reset_im_context (GTK_ENTRY (widget));
@@ -6244,10 +9573,15 @@ keypress_completion_out:
 
       return TRUE;
     }
-  else if (event->keyval == GDK_ISO_Enter ||
-           event->keyval == GDK_KP_Enter ||
-          event->keyval == GDK_Return)
+  else if (event->keyval == GDK_KEY_ISO_Enter ||
+           event->keyval == GDK_KEY_KP_Enter ||
+          event->keyval == GDK_KEY_Return)
     {
+      GtkTreeIter iter;
+      GtkTreeModel *model = NULL;
+      GtkTreeModel *child_model;
+      GtkTreeIter child_iter;
+      GtkTreeSelection *sel;
       gboolean retval = TRUE;
 
       _gtk_entry_reset_im_context (GTK_ENTRY (widget));
@@ -6255,17 +9589,16 @@ keypress_completion_out:
 
       if (completion->priv->current_selected < matches)
         {
-          GtkTreeIter iter;
-          GtkTreeModel *model = NULL;
-          GtkTreeSelection *sel;
           gboolean entry_set;
 
           sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (completion->priv->tree_view));
           if (gtk_tree_selection_get_selected (sel, &model, &iter))
             {
+              gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER (model), &child_iter, &iter);
+              child_model = gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (model));
               g_signal_handler_block (widget, completion->priv->changed_id);
               g_signal_emit_by_name (completion, "match-selected",
-                                     model, &iter, &entry_set);
+                                     child_model, &child_iter, &entry_set);
               g_signal_handler_unblock (widget, completion->priv->changed_id);
 
               if (!entry_set)
@@ -6289,15 +9622,18 @@ keypress_completion_out:
         }
       else if (completion->priv->current_selected - matches >= 0)
         {
-          GtkTreePath *path;
-
-          _gtk_entry_reset_im_context (GTK_ENTRY (widget));
-
-          path = gtk_tree_path_new_from_indices (completion->priv->current_selected - matches, -1);
+          sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (completion->priv->action_view));
+          if (gtk_tree_selection_get_selected (sel, &model, &iter))
+            {
+              GtkTreePath *path;
 
-          g_signal_emit_by_name (completion, "action-activated",
-                                 gtk_tree_path_get_indices (path)[0]);
-          gtk_tree_path_free (path);
+              path = gtk_tree_path_new_from_indices (completion->priv->current_selected - matches, -1);
+              g_signal_emit_by_name (completion, "action-activated",
+                                     gtk_tree_path_get_indices (path)[0]);
+              gtk_tree_path_free (path);
+            }
+          else
+            retval = FALSE;
         }
 
       g_free (completion->priv->completion_prefix);
@@ -6310,27 +9646,38 @@ keypress_completion_out:
 }
 
 static void
-gtk_entry_completion_changed (GtkWidget *entry,
+gtk_entry_completion_changed (GtkWidget *widget,
                               gpointer   user_data)
 {
   GtkEntryCompletion *completion = GTK_ENTRY_COMPLETION (user_data);
+  GtkEntry *entry = GTK_ENTRY (widget);
+  GtkEntryPrivate *priv = entry->priv;
+  GdkDevice *device;
 
   /* (re)install completion timeout */
   if (completion->priv->completion_timeout)
     g_source_remove (completion->priv->completion_timeout);
 
-  if (!gtk_entry_get_text (GTK_ENTRY (entry)))
+  if (!gtk_entry_get_text (entry))
     return;
 
   /* no need to normalize for this test */
   if (completion->priv->minimum_key_length > 0 &&
-      strcmp ("", gtk_entry_get_text (GTK_ENTRY (entry))) == 0)
+      strcmp ("", gtk_entry_get_text (entry)) == 0)
     {
-      if (GTK_WIDGET_VISIBLE (completion->priv->popup_window))
+      if (gtk_widget_get_visible (completion->priv->popup_window))
         _gtk_entry_completion_popdown (completion);
       return;
     }
 
+  device = gtk_get_current_event_device ();
+
+  if (device && gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD)
+    device = gdk_device_get_associated_device (device);
+
+  if (device)
+    priv->completion_device = device;
+
   completion->priv->completion_timeout =
     gdk_threads_add_timeout (COMPLETION_TIMEOUT,
                    gtk_entry_completion_timeout,
@@ -6368,7 +9715,7 @@ accept_completion_callback (GtkEntry *entry)
 
   if (completion->priv->has_completion)
     gtk_editable_set_position (GTK_EDITABLE (entry),
-                              entry->text_length);
+                              gtk_entry_buffer_get_length (get_buffer (entry)));
 
   return FALSE;
 }
@@ -6468,7 +9815,7 @@ connect_completion_signals (GtkEntry           *entry,
 /**
  * gtk_entry_set_completion:
  * @entry: A #GtkEntry
- * @completion: The #GtkEntryCompletion or %NULL
+ * @completion: (allow-none): The #GtkEntryCompletion or %NULL
  *
  * Sets @completion to be the auxiliary completion object to use with @entry.
  * All further configuration of the completion mechanism is done on
@@ -6499,7 +9846,7 @@ gtk_entry_set_completion (GtkEntry           *entry,
           old->priv->completion_timeout = 0;
         }
 
-      if (GTK_WIDGET_MAPPED (old->priv->popup_window))
+      if (gtk_widget_get_mapped (old->priv->popup_window))
         _gtk_entry_completion_popdown (old);
 
       disconnect_completion_signals (entry, old);
@@ -6528,7 +9875,8 @@ gtk_entry_set_completion (GtkEntry           *entry,
  *
  * Returns the auxiliary completion object currently in use by @entry.
  *
- * Return value: The auxiliary completion object currently in use by @entry.
+ * Return value: (transfer none): The auxiliary completion object currently
+ *     in use by @entry.
  *
  * Since: 2.4
  */
@@ -6585,9 +9933,9 @@ gtk_entry_set_cursor_hadjustment (GtkEntry      *entry,
  * Retrieves the horizontal cursor adjustment for the entry. 
  * See gtk_entry_set_cursor_hadjustment().
  *
- * Return value: the horizontal cursor adjustment, or %NULL 
+ * Return value: (transfer none): the horizontal cursor adjustment, or %NULL
  *   if none has been set.
- * 
+ *
  * Since: 2.12
  */
 GtkAdjustment*
@@ -6598,171 +9946,254 @@ gtk_entry_get_cursor_hadjustment (GtkEntry *entry)
   return g_object_get_qdata (G_OBJECT (entry), quark_cursor_hadjustment);
 }
 
-/* Caps Lock warning for password entries */
-
-static void
-capslock_feedback_free (GtkEntryCapslockFeedback *feedback)
+/**
+ * gtk_entry_set_progress_fraction:
+ * @entry: a #GtkEntry
+ * @fraction: fraction of the task that's been completed
+ *
+ * Causes the entry's progress indicator to "fill in" the given
+ * fraction of the bar. The fraction should be between 0.0 and 1.0,
+ * inclusive.
+ *
+ * Since: 2.16
+ */
+void
+gtk_entry_set_progress_fraction (GtkEntry *entry,
+                                 gdouble   fraction)
 {
-  if (feedback->window)
-    gtk_widget_destroy (feedback->window);
+  GtkWidget       *widget;
+  GtkEntryPrivate *private;
+  gdouble          old_fraction;
+  gint x, y, width, height;
+  gint old_x, old_y, old_width, old_height;
 
-  g_slice_free (GtkEntryCapslockFeedback, feedback);
-}
+  g_return_if_fail (GTK_IS_ENTRY (entry));
 
-static gboolean
-capslock_feedback_expose_event_cb (GtkWidget                *widget,
-                                   GdkEventExpose           *event,
-                                   GtkEntryCapslockFeedback *feedback)
-{
-  gtk_paint_flat_box (feedback->window->style,
-                      feedback->window->window,
-                      GTK_STATE_NORMAL,
-                      GTK_SHADOW_OUT,
-                      NULL,
-                      feedback->window,
-                      "tooltip",
-                      0, 0,
-                      feedback->window->allocation.width,
-                      feedback->window->allocation.height);
-  return FALSE;
+  widget = GTK_WIDGET (entry);
+  private = entry->priv;
+
+  if (private->progress_pulse_mode)
+    old_fraction = -1;
+  else
+    old_fraction = private->progress_fraction;
+
+  if (gtk_widget_is_drawable (widget))
+    get_progress_area (widget, &old_x, &old_y, &old_width, &old_height);
+
+  fraction = CLAMP (fraction, 0.0, 1.0);
+
+  private->progress_fraction = fraction;
+  private->progress_pulse_mode = FALSE;
+  private->progress_pulse_current = 0.0;
+
+  if (gtk_widget_is_drawable (widget))
+    {
+      get_progress_area (widget, &x, &y, &width, &height);
+
+      if ((x != old_x) || (y != old_y) || (width != old_width) || (height != old_height))
+        gtk_widget_queue_draw (widget);
+    }
+
+  if (fraction != old_fraction)
+    g_object_notify (G_OBJECT (entry), "progress-fraction");
 }
 
-static gboolean
-capslock_feedback_enter_notify (GtkWidget                *widget,
-                                GdkEventCrossing         *event,
-                                GtkEntryCapslockFeedback *feedback)
+/**
+ * gtk_entry_get_progress_fraction:
+ * @entry: a #GtkEntry
+ *
+ * Returns the current fraction of the task that's been completed.
+ * See gtk_entry_set_progress_fraction().
+ *
+ * Return value: a fraction from 0.0 to 1.0
+ *
+ * Since: 2.16
+ */
+gdouble
+gtk_entry_get_progress_fraction (GtkEntry *entry)
 {
-  remove_capslock_feedback (GTK_ENTRY (feedback->entry));
-  return TRUE;
+  g_return_val_if_fail (GTK_IS_ENTRY (entry), 0.0);
+
+  return entry->priv->progress_fraction;
 }
 
-static void
-create_capslock_feedback_window (GtkEntryCapslockFeedback *feedback)
+/**
+ * gtk_entry_set_progress_pulse_step:
+ * @entry: a #GtkEntry
+ * @fraction: fraction between 0.0 and 1.0
+ *
+ * Sets the fraction of total entry width to move the progress
+ * bouncing block for each call to gtk_entry_progress_pulse().
+ *
+ * Since: 2.16
+ */
+void
+gtk_entry_set_progress_pulse_step (GtkEntry *entry,
+                                   gdouble   fraction)
 {
-  GtkWidget *window;
-  GtkWidget *alignment;
-  GtkWidget *label;
-  
-  /* Keep in sync with gtk_tooltip_init() */
-  window = feedback->window = gtk_window_new (GTK_WINDOW_POPUP);
-  gtk_window_set_type_hint (GTK_WINDOW (window), GDK_WINDOW_TYPE_HINT_TOOLTIP);
-  gtk_widget_set_app_paintable (window, TRUE);
-  gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
-  gtk_widget_set_name (window, "gtk-tooltip");
-
-  alignment = gtk_alignment_new (0.5, 0.5, 1.0, 1.0);
-  gtk_alignment_set_padding (GTK_ALIGNMENT (alignment),
-                             window->style->ythickness, 
-                             window->style->ythickness,
-                             window->style->xthickness,
-                             window->style->xthickness);
-  gtk_container_add (GTK_CONTAINER (window), alignment);
-  gtk_widget_show (alignment);
-
-  g_signal_connect (window, "expose-event",
-                    G_CALLBACK (capslock_feedback_expose_event_cb), feedback);
-  g_signal_connect (window, "enter-notify-event",
-                    G_CALLBACK (capslock_feedback_enter_notify), feedback);
-
-  label = feedback->label = gtk_label_new (NULL);
-  gtk_container_add (GTK_CONTAINER (alignment), label);
-  gtk_widget_show (label);
+  GtkEntryPrivate *private;
+
+  g_return_if_fail (GTK_IS_ENTRY (entry));
+
+  private = entry->priv;
+
+  fraction = CLAMP (fraction, 0.0, 1.0);
+
+  if (fraction != private->progress_pulse_fraction)
+    {
+      private->progress_pulse_fraction = fraction;
+
+      gtk_widget_queue_draw (GTK_WIDGET (entry));
+
+      g_object_notify (G_OBJECT (entry), "progress-pulse-step");
+    }
 }
 
-static void
-show_capslock_feedback_window (GtkEntryCapslockFeedback *feedback)
+/**
+ * gtk_entry_get_progress_pulse_step:
+ * @entry: a #GtkEntry
+ *
+ * Retrieves the pulse step set with gtk_entry_set_progress_pulse_step().
+ *
+ * Return value: a fraction from 0.0 to 1.0
+ *
+ * Since: 2.16
+ */
+gdouble
+gtk_entry_get_progress_pulse_step (GtkEntry *entry)
 {
-  GtkRequisition feedback_req;
-  gint entry_x, entry_y;
-  GtkAllocation *entry_allocation;
-  int feedback_x, feedback_y;
-  GdkScreen *screen;
-  gint monitor_num;
-  GdkRectangle monitor;
-  GtkWidget *entry;
+  g_return_val_if_fail (GTK_IS_ENTRY (entry), 0.0);
 
-  entry = feedback->entry;
-  screen = gtk_widget_get_screen (entry);
-  monitor_num = gdk_screen_get_monitor_at_window (screen, entry->window);
-  gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
+  return entry->priv->progress_pulse_fraction;
+}
 
-  feedback = g_object_get_qdata (G_OBJECT (entry), quark_capslock_feedback);
+/**
+ * gtk_entry_progress_pulse:
+ * @entry: a #GtkEntry
+ *
+ * Indicates that some progress is made, but you don't know how much.
+ * Causes the entry's progress indicator to enter "activity mode,"
+ * where a block bounces back and forth. Each call to
+ * gtk_entry_progress_pulse() causes the block to move by a little bit
+ * (the amount of movement per pulse is determined by
+ * gtk_entry_set_progress_pulse_step()).
+ *
+ * Since: 2.16
+ */
+void
+gtk_entry_progress_pulse (GtkEntry *entry)
+{
+  GtkEntryPrivate *private;
 
-  gtk_widget_size_request (feedback->window, &feedback_req);
+  g_return_if_fail (GTK_IS_ENTRY (entry));
 
-  gdk_window_get_origin (entry->window, &entry_x, &entry_y);
-  entry_allocation = &(entry->allocation);
+  private = entry->priv;
 
-  if (entry_x + feedback_req.width <= monitor.x + monitor.width)
-      feedback_x = MAX (entry_x, monitor.x);
-  else
-    feedback_x = monitor.x + monitor.width - feedback_req.width;
+  if (private->progress_pulse_mode)
+    {
+      if (private->progress_pulse_way_back)
+        {
+          private->progress_pulse_current -= private->progress_pulse_fraction;
+
+          if (private->progress_pulse_current < 0.0)
+            {
+              private->progress_pulse_current = 0.0;
+              private->progress_pulse_way_back = FALSE;
+            }
+        }
+      else
+        {
+          private->progress_pulse_current += private->progress_pulse_fraction;
 
-  if (entry_y + entry_allocation->height + feedback_req.height <= monitor.y + monitor.height)
-    feedback_y = entry_y + entry_allocation->height;
+          if (private->progress_pulse_current > 1.0 - private->progress_pulse_fraction)
+            {
+              private->progress_pulse_current = 1.0 - private->progress_pulse_fraction;
+              private->progress_pulse_way_back = TRUE;
+            }
+        }
+    }
   else
-    feedback_y = MAX (entry_y - feedback_req.height, monitor.y);
+    {
+      private->progress_fraction = 0.0;
+      private->progress_pulse_mode = TRUE;
+      private->progress_pulse_way_back = FALSE;
+      private->progress_pulse_current = 0.0;
+    }
 
-  gtk_window_move (GTK_WINDOW (feedback->window), feedback_x, feedback_y);
-  gtk_widget_show (feedback->window);
+  gtk_widget_queue_draw (GTK_WIDGET (entry));
 }
 
+/* Caps Lock warning for password entries */
+
 static void
-pop_up_capslock_feedback (GtkEntry    *entry,
-                          const gchar *text)
+show_capslock_feedback (GtkEntry    *entry,
+                        const gchar *text)
 {
-  GtkEntryCapslockFeedback *feedback;
+  GtkEntryPrivate *priv = entry->priv;
 
-  feedback = g_object_get_qdata (G_OBJECT (entry), quark_capslock_feedback);
-
-  if (feedback == NULL)
+  if (gtk_entry_get_icon_storage_type (entry, GTK_ENTRY_ICON_SECONDARY) == GTK_IMAGE_EMPTY)
     {
-      feedback = g_slice_new0 (GtkEntryCapslockFeedback);
-      feedback->entry = entry;
-      g_object_set_qdata_full (G_OBJECT (entry), quark_capslock_feedback,
-                               feedback,
-                               (GDestroyNotify) capslock_feedback_free);
-      create_capslock_feedback_window (feedback);
+      gtk_entry_set_icon_from_stock (entry, GTK_ENTRY_ICON_SECONDARY, GTK_STOCK_CAPS_LOCK_WARNING);
+      gtk_entry_set_icon_activatable (entry, GTK_ENTRY_ICON_SECONDARY, FALSE);
+      priv->caps_lock_warning_shown = TRUE;
     }
 
-  gtk_label_set_text (GTK_LABEL (feedback->label), text);
-  show_capslock_feedback_window (feedback);
+  if (priv->caps_lock_warning_shown)
+    gtk_entry_set_icon_tooltip_text (entry, GTK_ENTRY_ICON_SECONDARY, text);
+  else
+    g_warning ("Can't show Caps Lock warning, since secondary icon is set");
 }
 
 static void
 remove_capslock_feedback (GtkEntry *entry)
 {
-  g_object_set_qdata (G_OBJECT (entry), quark_capslock_feedback, NULL);
+  GtkEntryPrivate *priv = entry->priv;
+
+  if (priv->caps_lock_warning_shown)
+    {
+      gtk_entry_set_icon_from_stock (entry, GTK_ENTRY_ICON_SECONDARY, NULL);
+      priv->caps_lock_warning_shown = FALSE;
+    } 
 }
 
 static void
 keymap_state_changed (GdkKeymap *keymap, 
                       GtkEntry  *entry)
 {
-  GtkEntryPrivate *priv = GTK_ENTRY_GET_PRIVATE (entry);
+  GtkEntryPrivate *priv = entry->priv;
   char *text = NULL;
 
-  if (!entry->visible && priv->caps_lock_warning)
+  if (gtk_entry_get_display_mode (entry) != DISPLAY_NORMAL && priv->caps_lock_warning)
     { 
-      gboolean capslock_on;
-      gboolean im_on;
-
-      capslock_on = gdk_keymap_get_caps_lock_state (keymap);
-      im_on = g_strcmp0 (gtk_im_multicontext_get_context_id (GTK_IM_MULTICONTEXT (entry->im_context)), "gtk-im-context-simple") != 0;
-      if (capslock_on && im_on)
-        text = _("You have the Caps Lock key on\nand an active input method");
-      else if (capslock_on)
-        text = _("You have the Caps Lock key on");
-      else if (im_on)
-        text = _("You have an active input method");    
+      if (gdk_keymap_get_num_lock_state (keymap)
+          && gdk_keymap_get_caps_lock_state (keymap))
+        text = _("Caps Lock and Num Lock are on");
+      else if (gdk_keymap_get_num_lock_state (keymap))
+        text = _("Num Lock is on");
+      else if (gdk_keymap_get_caps_lock_state (keymap))
+        text = _("Caps Lock is on");
     }
 
   if (text)
-    pop_up_capslock_feedback (entry, text);
+    show_capslock_feedback (entry, text);
   else
     remove_capslock_feedback (entry);
 }
 
-
-#define __GTK_ENTRY_C__
-#include "gtkaliasdef.c"
+/*
+ * _gtk_entry_set_is_cell_renderer:
+ * @entry: a #GtkEntry
+ * @is_cell_renderer: new value
+ *
+ * This is a helper function for GtkComboBox. A GtkEntry in a GtkComboBox
+ * is supposed to behave like a GtkCellEditable when placed in a combo box.
+ *
+ * I.e take up its allocation and get GtkEntry->is_cell_renderer = TRUE.
+ *
+ */
+void
+_gtk_entry_set_is_cell_renderer (GtkEntry *entry,
+                                 gboolean  is_cell_renderer)
+{
+  entry->priv->is_cell_renderer = is_cell_renderer;
+}