[evolution-data-server/gnome-3-6] Speed-up auto-completion results showing



commit 1f138d6516232b0860540c85427af84d8575130d
Author: Milan Crha <mcrha redhat com>
Date:   Wed Feb 27 20:10:17 2013 +0100

    Speed-up auto-completion results showing
    
    The results were postponed to show as long as there were new notifications
    about added contacts, which could take quite long for many matched items.
    This shows the results with smaller timeout and without postponing.

 libedataserverui/e-name-selector-entry.c |   33 ++++++++++++++++++++----------
 1 files changed, 22 insertions(+), 11 deletions(-)
---
diff --git a/libedataserverui/e-name-selector-entry.c b/libedataserverui/e-name-selector-entry.c
index f8987f2..da115d0 100644
--- a/libedataserverui/e-name-selector-entry.c
+++ b/libedataserverui/e-name-selector-entry.c
@@ -95,11 +95,14 @@ G_DEFINE_TYPE_WITH_CODE (
 /* 1/3 of the second to wait until invoking autocomplete lookup */
 #define AUTOCOMPLETE_TIMEOUT 333
 
-#define re_set_timeout(id,func,ptr)                    \
-       if (id)                                         \
-               g_source_remove (id);                   \
-       id = g_timeout_add (AUTOCOMPLETE_TIMEOUT,       \
-                           (GSourceFunc) func, ptr);
+/* 1/20 of a second to wait until show the completion results */
+#define SHOW_RESULT_TIMEOUT 50
+
+#define re_set_timeout(id,func,ptr,tout) G_STMT_START {                \
+       if (id)                                                 \
+               g_source_remove (id);                           \
+       id = g_timeout_add (tout, (GSourceFunc) func, ptr);     \
+       } G_STMT_END
 
 static void destination_row_inserted (ENameSelectorEntry *name_selector_entry, GtkTreePath *path, 
GtkTreeIter *iter);
 static void destination_row_changed  (ENameSelectorEntry *name_selector_entry, GtkTreePath *path, 
GtkTreeIter *iter);
@@ -1511,8 +1514,10 @@ user_insert_text (ENameSelectorEntry *name_selector_entry,
 
        if (chars_inserted >= 1) {
                /* If the user inserted one character, kick off completion */
-               re_set_timeout (name_selector_entry->priv->update_completions_cb_id,  
update_completions_on_timeout_cb,  name_selector_entry);
-               re_set_timeout (name_selector_entry->priv->type_ahead_complete_cb_id, 
type_ahead_complete_on_timeout_cb, name_selector_entry);
+               re_set_timeout (name_selector_entry->priv->update_completions_cb_id,
+                       update_completions_on_timeout_cb,  name_selector_entry, AUTOCOMPLETE_TIMEOUT);
+               re_set_timeout (name_selector_entry->priv->type_ahead_complete_cb_id,
+                       type_ahead_complete_on_timeout_cb, name_selector_entry, AUTOCOMPLETE_TIMEOUT);
        }
 
        g_signal_handlers_unblock_by_func (name_selector_entry, user_delete_text, name_selector_entry);
@@ -1555,7 +1560,8 @@ user_delete_text (ENameSelectorEntry *name_selector_entry,
 
        if (end_pos - start_pos == 1) {
                /* Might be backspace; update completion model so dropdown is accurate */
-               re_set_timeout (name_selector_entry->priv->update_completions_cb_id, 
update_completions_on_timeout_cb, name_selector_entry);
+               re_set_timeout (name_selector_entry->priv->update_completions_cb_id,
+                       update_completions_on_timeout_cb, name_selector_entry, AUTOCOMPLETE_TIMEOUT);
        }
 
        index_start = get_index_at_position (text, start_pos);
@@ -2164,9 +2170,14 @@ generate_contact_rows (EContactStore *contact_store,
 static void
 ensure_type_ahead_complete_on_timeout (ENameSelectorEntry *name_selector_entry)
 {
-       re_set_timeout (
-               name_selector_entry->priv->type_ahead_complete_cb_id,
-               type_ahead_complete_on_timeout_cb, name_selector_entry);
+       /* this is called whenever a new item is added to the model,
+          thus, to not starve when there are many matches, do not
+          postpone on each add, but show results as soon as possible */
+       if (!name_selector_entry->priv->type_ahead_complete_cb_id) {
+               re_set_timeout (
+                       name_selector_entry->priv->type_ahead_complete_cb_id,
+                       type_ahead_complete_on_timeout_cb, name_selector_entry, SHOW_RESULT_TIMEOUT);
+       }
 }
 
 static gboolean


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