[epiphany] Make text search faster by delaying the actual search
- From: Gustavo Noronha Silva <gns src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [epiphany] Make text search faster by delaying the actual search
- Date: Fri, 15 Jan 2010 21:52:11 +0000 (UTC)
commit b573119b1338722ba9f6016b72064f6fcf681dfc
Author: Gustavo Noronha Silva <gns gnome org>
Date: Fri Dec 25 23:58:59 2009 -0200
Make text search faster by delaying the actual search
This makes sure that we do not search for 1-2 characters when the user
starts typing, making the search for longer words faster.
Bug #598322
src/ephy-find-toolbar.c | 35 +++++++++++++++++++++++++++++++----
1 files changed, 31 insertions(+), 4 deletions(-)
---
diff --git a/src/ephy-find-toolbar.c b/src/ephy-find-toolbar.c
index 71f2552..196957d 100644
--- a/src/ephy-find-toolbar.c
+++ b/src/ephy-find-toolbar.c
@@ -48,6 +48,7 @@ struct _EphyFindToolbarPrivate
gulong set_focus_handler;
guint source_id;
guint find_again_source_id;
+ guint find_source_id;
char *find_string;
guint preedit_changed : 1;
guint prevent_activate : 1;
@@ -268,20 +269,40 @@ real_find (EphyFindToolbarPrivate *priv,
return EPHY_FIND_FOUND;
}
+static gboolean
+do_search (EphyFindToolbar *toolbar)
+{
+ EphyFindToolbarPrivate *priv = toolbar->priv;
+ EphyEmbedFindResult result;
+
+ priv->find_source_id = 0;
+
+ ephy_find_toolbar_mark_matches (toolbar);
+
+ result = real_find (priv, TRUE);
+ set_status (toolbar, result);
+
+ return FALSE;
+}
+
static void
entry_changed_cb (GtkEntry *entry,
EphyFindToolbar *toolbar)
{
EphyFindToolbarPrivate *priv = toolbar->priv;
- EphyEmbedFindResult result;
g_free (priv->find_string);
priv->find_string = g_strdup (gtk_entry_get_text (GTK_ENTRY (priv->entry)));
- ephy_find_toolbar_mark_matches (toolbar);
+ if (priv->find_source_id != 0) {
+ g_source_remove (priv->find_source_id);
+ priv->find_source_id = 0;
+ }
- result = real_find (priv, TRUE);
- set_status (toolbar, result);
+ if (strlen (priv->find_string) == 0)
+ return;
+
+ priv->find_source_id = g_timeout_add (300, (GSourceFunc)do_search, toolbar);
}
static gboolean
@@ -612,6 +633,12 @@ ephy_find_toolbar_dispose (GObject *object)
priv->find_again_source_id = 0;
}
+ if (priv->find_source_id != 0)
+ {
+ g_source_remove (priv->find_source_id);
+ priv->find_source_id = 0;
+ }
+
G_OBJECT_CLASS (ephy_find_toolbar_parent_class)->dispose (object);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]