From ed664236929a6e2ab4c188180c9e19de75684f09 Mon Sep 17 00:00:00 2001 From: Claudio Saavedra Date: Tue, 15 Jun 2010 17:43:52 +0300 Subject: Don't filter asynchronously when hildon_live_search_set_text() called This is because calls to hildon_live_search_set_text() followed by a retrieval of the selection will then break, and at least addressbook assumes that this will happen synchronously. Since we only want to give better responsiveness in the case when the user is typing, no need to go fully asynchronously. --- hildon/hildon-live-search.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/hildon/hildon-live-search.c b/hildon/hildon-live-search.c index 922c5ad..f196e73 100644 --- a/hildon/hildon-live-search.c +++ b/hildon/hildon-live-search.c @@ -70,6 +70,7 @@ struct _HildonLiveSearchPrivate gpointer visible_data; GDestroyNotify visible_destroy; gboolean visible_func_set; + gboolean run_async; }; enum @@ -440,8 +441,16 @@ on_entry_changed (GtkEntry *entry, g_free (priv->prefix); priv->prefix = g_strdup (text); - if (priv->idle_filter_id == 0) { - priv->idle_filter_id = gdk_threads_add_idle ((GSourceFunc) on_idle_refilter, livesearch); + if (priv->run_async) { + if (priv->idle_filter_id == 0) { + priv->idle_filter_id = gdk_threads_add_idle ((GSourceFunc) on_idle_refilter, livesearch); + } + } else { + if (priv->idle_filter_id != 0) { + g_source_remove (priv->idle_filter_id); + priv->idle_filter_id = 0; + } + on_idle_refilter (livesearch); } /* Show the livesearch only if there is text in it */ @@ -502,8 +511,10 @@ hildon_live_search_set_text (HildonLiveSearch *livesearch, g_return_if_fail (HILDON_IS_LIVE_SEARCH (livesearch)); g_return_if_fail (NULL != text); + livesearch->priv->run_async = FALSE; gtk_entry_set_text (GTK_ENTRY (livesearch->priv->entry), text); + livesearch->priv->run_async = TRUE; /* GObject::notify::text for HildonLiveSearch:text emitted in the handler for GtkEntry::changed. */ @@ -791,6 +802,7 @@ hildon_live_search_init (HildonLiveSearch *self) priv->idle_filter_id = 0; priv->selection_map = NULL; + priv->run_async = TRUE; priv->text_column = -1; -- cgit v1.2.3-18-g5258