[gnome-contacts] Delay showing of link hints to make scrolling faster



commit e7424b256053c975ea1c7aaf0b7dfb30a6b4bde4
Author: Alexander Larsson <alexl redhat com>
Date:   Mon May 14 16:19:57 2012 +0200

    Delay showing of link hints to make scrolling faster
    
    Actually finding the matches takes some time which causes keynav
    to become pretty slow.

 src/contacts-app.vala          |    2 +-
 src/contacts-contact-pane.vala |   31 +++++++++++++++++++++++--------
 2 files changed, 24 insertions(+), 9 deletions(-)
---
diff --git a/src/contacts-app.vala b/src/contacts-app.vala
index 5771396..ad9ad7d 100644
--- a/src/contacts-app.vala
+++ b/src/contacts-app.vala
@@ -59,7 +59,7 @@ public class Contacts.App : Gtk.Application {
   }
 
   private void selection_changed (Contact? new_selection) {
-    contacts_pane.show_contact (new_selection);
+    contacts_pane.show_contact (new_selection, false, false);
   }
 
   public void show_contact (Contact? contact) {
diff --git a/src/contacts-contact-pane.vala b/src/contacts-contact-pane.vala
index 8a9a46f..2a5526a 100644
--- a/src/contacts-contact-pane.vala
+++ b/src/contacts-contact-pane.vala
@@ -1802,7 +1802,13 @@ public class Contacts.ContactPane : ScrolledWindow {
     grid.attach (bbox, 2, 0, 1, 2);
   }
 
-  public void update_personas () {
+  private uint update_personas_timeout;
+  public void update_personas (bool show_matches = true) {
+    if (update_personas_timeout != 0) {
+      Source.remove (update_personas_timeout);
+      update_personas_timeout = 0;
+    }
+
     foreach (var w in personas_grid.get_children ()) {
       w.destroy ();
     }
@@ -1818,18 +1824,20 @@ public class Contacts.ContactPane : ScrolledWindow {
       personas_grid.add (sheet);
     }
 
-    var matches = contact.store.aggregator.get_potential_matches (contact.individual, MatchResult.HIGH);
-    foreach (var ind in matches.keys) {
-      var c = Contact.from_individual (ind);
-      if (c != null && contact.suggest_link_to (c)) {
-	add_suggestion (c);
+    if (show_matches) {
+      var matches = contact.store.aggregator.get_potential_matches (contact.individual, MatchResult.HIGH);
+      foreach (var ind in matches.keys) {
+	var c = Contact.from_individual (ind);
+	if (c != null && contact.suggest_link_to (c)) {
+	  add_suggestion (c);
+	}
       }
     }
 
     personas_grid.show_all ();
   }
 
-  public void show_contact (Contact? new_contact, bool edit=false) {
+  public void show_contact (Contact? new_contact, bool edit=false, bool show_matches = true) {
     if (contact == new_contact)
       return;
 
@@ -1844,7 +1852,14 @@ public class Contacts.ContactPane : ScrolledWindow {
     contact = new_contact;
 
     update_card ();
-    update_personas ();
+    update_personas (show_matches);
+
+    if (!show_matches) {
+      update_personas_timeout = Gdk.threads_add_timeout (100, () => {
+	  update_personas ();
+	  return false;
+	});
+    }
 
     bool can_remove = false;
 



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