[gtk+/quartz-integration: 422/563] Fix up signal ordering issues in GtkEntry



commit de40e73f911a53c0f4764e18ad1e53a6d35a8b91
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Jun 25 18:49:54 2011 -0400

    Fix up signal ordering issues in GtkEntry
    
    Ensure that text and selection boundaries are in a
    consistent state when we emit notifications, that ::insert-text
    and ::delete-text are emitted before any changes, and that
    ::changed is emitted after property notifications when inserting
    or deleting text.

 gtk/gtkentry.c |   24 ++++++++++++++++++++----
 1 files changed, 20 insertions(+), 4 deletions(-)
---
diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c
index f5088e7..e58b107 100644
--- a/gtk/gtkentry.c
+++ b/gtk/gtkentry.c
@@ -4648,8 +4648,14 @@ gtk_entry_real_insert_text (GtkEditable *editable,
    * following signal handlers: buffer_inserted_text(), buffer_notify_display_text(),
    * buffer_notify_text(), buffer_notify_length()
    */
+  begin_change (GTK_ENTRY (editable));
+  g_object_freeze_notify (G_OBJECT (editable));
+
   n_inserted = gtk_entry_buffer_insert_text (get_buffer (GTK_ENTRY (editable)), *position, new_text, n_chars);
 
+  g_object_thaw_notify (G_OBJECT (editable));
+  end_change (GTK_ENTRY (editable));
+
   if (n_inserted != n_chars)
       gtk_widget_error_bell (GTK_WIDGET (editable));
 
@@ -4667,7 +4673,11 @@ gtk_entry_real_delete_text (GtkEditable *editable,
    * buffer_notify_text(), buffer_notify_length()
    */
 
+  begin_change (GTK_ENTRY (editable));
+  g_object_freeze_notify (G_OBJECT (editable));
   gtk_entry_buffer_delete_text (get_buffer (GTK_ENTRY (editable)), start_pos, end_pos - start_pos);
+  g_object_thaw_notify (G_OBJECT (editable));
+  end_change (GTK_ENTRY (editable));
 }
 
 /* GtkEntryBuffer signal handlers
@@ -4681,12 +4691,18 @@ buffer_inserted_text (GtkEntryBuffer *buffer,
 {
   GtkEntryPrivate *priv = entry->priv;
   guint password_hint_timeout;
+  guint current_pos;
+  gint selection_bound;
+
+  current_pos = priv->current_pos;
+  if (current_pos > position)
+    current_pos += n_chars;
 
-  if (priv->current_pos > position)
-    priv->current_pos += n_chars;
+  selection_bound = priv->selection_bound;
+  if (selection_bound > position)
+    selection_bound += n_chars;
 
-  if (priv->selection_bound > position)
-    priv->selection_bound += n_chars;
+  gtk_entry_set_positions (entry, current_pos, selection_bound);
 
   /* Calculate the password hint if it needs to be displayed. */
   if (n_chars == 1 && !priv->visible)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]