[gnome-contacts] Fake has_notes when we just set it, to avoid ui delay



commit bd95f33b6778b89d9e6e94851b313b64f26289d0
Author: Alexander Larsson <alexl redhat com>
Date:   Thu Oct 20 18:52:28 2011 +0200

    Fake has_notes when we just set it, to avoid ui delay
    
    This means the dot is immediately set correctly, rather than after
    the async set call is finished.

 src/contacts-contact-pane.vala |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)
---
diff --git a/src/contacts-contact-pane.vala b/src/contacts-contact-pane.vala
index a6351a5..0e18f2a 100644
--- a/src/contacts-contact-pane.vala
+++ b/src/contacts-contact-pane.vala
@@ -322,6 +322,7 @@ public class Contacts.ContactPane : Grid {
   private MenuItem delete_menu_item;
 
   private bool has_notes;
+  private bool keep_has_notes_once;
   private Widget notes_dot;
   private Widget empty_widget;
   private EventBox pane;
@@ -1098,6 +1099,7 @@ public class Contacts.ContactPane : Grid {
 
     foreach (var persona in widgets.get_keys ()) {
       bool modified = false;
+      bool empty = true;
 
       var notes = new HashSet<NoteFieldDetails> ();
       foreach (var view in widgets.get (persona)) {
@@ -1111,6 +1113,7 @@ public class Contacts.ContactPane : Grid {
 	if (is_set (text)) {
 	  var note = new NoteFieldDetails (text, null, uid);
 	  notes.add (note);
+	  empty = false;
 	}
       }
 
@@ -1126,6 +1129,10 @@ public class Contacts.ContactPane : Grid {
 	      warning ("Unable to save note: %s", e2.message);
 	    }
 	  });
+	// We fake has_notes content for this display_contact() run, to avoid
+	// the wait for the async property setter
+	keep_has_notes_once = true;
+	has_notes = !empty;
       }
     }
   }
@@ -1524,7 +1531,9 @@ public class Contacts.ContactPane : Grid {
   }
 
   private void set_has_notes (bool has_notes) {
-    this.has_notes = has_notes;
+    if (!keep_has_notes_once)
+      this.has_notes = has_notes;
+    keep_has_notes_once = false;
     notes_dot.queue_draw ();
   }
 



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