summaryrefslogtreecommitdiff
path: root/libempathy-gtk
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2012-10-02 14:59:55 +0200
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2012-10-02 15:14:54 +0200
commit35c4220f495a85db3d32df86d0a62a1039cdc915 (patch)
tree4998c53cea7393bdd3ceb3d74f40a6359e581873 /libempathy-gtk
parentee2b89a5cbd5b5837488c7334a259bc356eccdc4 (diff)
downloadempathy-35c4220f495a85db3d32df86d0a62a1039cdc915.tar.gz
roster-view: add some delay before actually starting the live search
This avoid stacking a bunch of useless searches while user is typing as we can't stop the old search before starting the new one. https://bugzilla.gnome.org/show_bug.cgi?id=685278
Diffstat (limited to 'libempathy-gtk')
-rw-r--r--libempathy-gtk/empathy-roster-view.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/libempathy-gtk/empathy-roster-view.c b/libempathy-gtk/empathy-roster-view.c
index d54bd052c..c3ae66e25 100644
--- a/libempathy-gtk/empathy-roster-view.c
+++ b/libempathy-gtk/empathy-roster-view.c
@@ -17,6 +17,10 @@ G_DEFINE_TYPE (EmpathyRosterView, empathy_roster_view, EGG_TYPE_LIST_BOX)
/* Flashing delay for icons (milliseconds). */
#define FLASH_TIMEOUT 500
+/* Delay in milliseconds between the last stroke on the keyboard and the start
+ * of the live search. */
+#define SEARCH_TIMEOUT 500
+
enum
{
PROP_MODEL = 1,
@@ -61,6 +65,8 @@ struct _EmpathyRosterViewPriv
guint flash_id;
gboolean display_flash_event;
+ guint search_id;
+
gboolean show_offline;
gboolean show_groups;
gboolean empty;
@@ -1078,6 +1084,12 @@ empathy_roster_view_dispose (GObject *object)
empathy_roster_view_set_live_search (self, NULL);
g_clear_object (&self->priv->model);
+ if (self->priv->search_id != 0)
+ {
+ g_source_remove (self->priv->search_id);
+ self->priv->search_id = 0;
+ }
+
if (chain_up != NULL)
chain_up (object);
}
@@ -1437,14 +1449,27 @@ select_first_contact (EmpathyRosterView *self)
g_list_free (children);
}
+static gboolean
+search_timeout_cb (EmpathyRosterView *self)
+{
+ egg_list_box_refilter (EGG_LIST_BOX (self));
+
+ select_first_contact (self);
+
+ self->priv->search_id = 0;
+ return G_SOURCE_REMOVE;
+}
+
static void
search_text_notify_cb (EmpathyLiveSearch *search,
GParamSpec *pspec,
EmpathyRosterView *self)
{
- egg_list_box_refilter (EGG_LIST_BOX (self));
+ if (self->priv->search_id != 0)
+ g_source_remove (self->priv->search_id);
- select_first_contact (self);
+ self->priv->search_id = g_timeout_add (SEARCH_TIMEOUT,
+ (GSourceFunc) search_timeout_cb, self);
}
static void