aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2013-02-22 02:07:37 +0800
committerMilan Crha <mcrha@redhat.com>2013-02-22 02:07:37 +0800
commite667bac9f91272c057072ed1286f3f8fd4e29ff7 (patch)
treeae4f63692a6db9397e0e082a59e143f8be117ac4
parentfcf360d0519649b43d047458e492677c027f6645 (diff)
downloadgsoc2013-evolution-e667bac9f91272c057072ed1286f3f8fd4e29ff7.tar
gsoc2013-evolution-e667bac9f91272c057072ed1286f3f8fd4e29ff7.tar.gz
gsoc2013-evolution-e667bac9f91272c057072ed1286f3f8fd4e29ff7.tar.bz2
gsoc2013-evolution-e667bac9f91272c057072ed1286f3f8fd4e29ff7.tar.lz
gsoc2013-evolution-e667bac9f91272c057072ed1286f3f8fd4e29ff7.tar.xz
gsoc2013-evolution-e667bac9f91272c057072ed1286f3f8fd4e29ff7.tar.zst
gsoc2013-evolution-e667bac9f91272c057072ed1286f3f8fd4e29ff7.zip
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.
-rw-r--r--e-util/e-name-selector-entry.c33
1 files changed, 22 insertions, 11 deletions
diff --git a/e-util/e-name-selector-entry.c b/e-util/e-name-selector-entry.c
index 25b018326a..544c8b5b51 100644
--- a/e-util/e-name-selector-entry.c
+++ b/e-util/e-name-selector-entry.c
@@ -93,11 +93,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);
@@ -1509,8 +1512,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, SHOW_RESULT_TIMEOUT);
}
g_signal_handlers_unblock_by_func (name_selector_entry, user_delete_text, name_selector_entry);
@@ -1553,7 +1558,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);
@@ -2162,9 +2168,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 void