[clutter/clutter-1.16] clutter-text: emitting ClutterText::delete-text before actual changes on the text



commit 3fe9c91da9ed24d4ca19b6edcd450dfa5d764ceb
Author: Alejandro Piñeiro <apinheiro igalia com>
Date:   Thu Jan 16 17:39:02 2014 +0100

    clutter-text: emitting ClutterText::delete-text before actual changes on the text
    
    https://bugzilla.gnome.org/show_bug.cgi?id=722220
    (cherry picked from commit bbc7d20f5ecff80f4000557b976e3153f6286252)
    Signed-off-by: Alejandro Piñeiro <apinheiro igalia com>

 clutter/clutter-text.c |   29 +++++++++++++++++++++++++----
 1 files changed, 25 insertions(+), 4 deletions(-)
---
diff --git a/clutter/clutter-text.c b/clutter/clutter-text.c
index 03090f6..abc5608 100644
--- a/clutter/clutter-text.c
+++ b/clutter/clutter-text.c
@@ -4297,8 +4297,6 @@ buffer_deleted_text (ClutterTextBuffer *buffer,
       if (priv->position != new_position || priv->selection_bound != new_selection_bound)
         clutter_text_set_positions (self, new_position, new_selection_bound);
     }
-
-  g_signal_emit (self, text_signals[DELETE_TEXT], 0, position, position + n_chars);
 }
 
 static void
@@ -5942,6 +5940,29 @@ clutter_text_insert_text (ClutterText *self,
                                    g_utf8_strlen (text, -1));
 }
 
+static
+void clutter_text_real_delete_text (ClutterText *self,
+                                    gssize       start_pos,
+                                    gssize       end_pos)
+{
+  /*
+   * delete-text is emitted here instead of as part of a
+   * buffer_deleted_text() callback because that should be emitted
+   * before the buffer changes, while ClutterTextBuffer::deleted-text
+   * is emitter after. See BG#722220 for more info.
+   */
+  g_signal_emit (self, text_signals[DELETE_TEXT], 0, start_pos, end_pos);
+
+  /*
+   * The actual deletion from the buffer. This will end firing the
+   * following signal handlers: buffer_deleted_text(),
+   * buffer_notify_text(), buffer_notify_max_length()
+   */
+  clutter_text_buffer_delete_text (get_buffer (self), start_pos, end_pos - start_pos);
+}
+
+
+
 /**
  * clutter_text_delete_text:
  * @self: a #ClutterText
@@ -5963,7 +5984,7 @@ clutter_text_delete_text (ClutterText *self,
 {
   g_return_if_fail (CLUTTER_IS_TEXT (self));
 
-  clutter_text_buffer_delete_text (get_buffer (self), start_pos, end_pos - start_pos);
+  clutter_text_real_delete_text (self, start_pos, end_pos);
 }
 
 /**
@@ -5989,7 +6010,7 @@ clutter_text_delete_chars (ClutterText *self,
 
   priv = self->priv;
 
-  clutter_text_buffer_delete_text (get_buffer (self), priv->position, n_chars);
+  clutter_text_real_delete_text (self, priv->position, n_chars);
 
   if (priv->position > 0)
     clutter_text_set_cursor_position (self, priv->position - n_chars);


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