[clutter] text: Avoid changing the contents when possible



commit e7511dd4695a0b817e439743d2263275814de72e
Author: Emmanuele Bassi <ebassi linux intel com>
Date:   Tue Feb 7 11:36:27 2012 +0000

    text: Avoid changing the contents when possible
    
    An editable ClutterText will reset the selection and cursor whenever the
    contents are changed â even if those contents are the same. As this may
    confuse the user, we should check if we're setting the exact same string,
    and bail out if necessary.

 clutter/clutter-text.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)
---
diff --git a/clutter/clutter-text.c b/clutter/clutter-text.c
index 0d18aef..5f72367 100644
--- a/clutter/clutter-text.c
+++ b/clutter/clutter-text.c
@@ -4742,6 +4742,16 @@ clutter_text_set_text (ClutterText *self,
 {
   g_return_if_fail (CLUTTER_IS_TEXT (self));
 
+  /* if the text is editable (i.e. there is not markup flag to reset) then
+   * changing the contents will result in selection and cursor changes that
+   * we should avoid
+   */
+  if (self->priv->editable)
+    {
+      if (strcmp (clutter_text_buffer_get_text (get_buffer (self)), text) == 0)
+        return;
+    }
+
   clutter_text_set_use_markup_internal (self, FALSE);
   clutter_text_buffer_set_text (get_buffer (self), text, -1);
 }



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