diff options
author | Gustavo Noronha Silva <gns@gnome.org> | 2009-12-26 09:58:59 +0800 |
---|---|---|
committer | Gustavo Noronha Silva <gns@gnome.org> | 2010-01-16 05:51:34 +0800 |
commit | b573119b1338722ba9f6016b72064f6fcf681dfc (patch) | |
tree | 0ad68177ff112b923ad67ae3d68cdbbb618d68ee /src/ephy-find-toolbar.c | |
parent | bac714eab6253cf088761501117937e9b48bcea9 (diff) | |
download | gsoc2013-epiphany-b573119b1338722ba9f6016b72064f6fcf681dfc.tar gsoc2013-epiphany-b573119b1338722ba9f6016b72064f6fcf681dfc.tar.gz gsoc2013-epiphany-b573119b1338722ba9f6016b72064f6fcf681dfc.tar.bz2 gsoc2013-epiphany-b573119b1338722ba9f6016b72064f6fcf681dfc.tar.lz gsoc2013-epiphany-b573119b1338722ba9f6016b72064f6fcf681dfc.tar.xz gsoc2013-epiphany-b573119b1338722ba9f6016b72064f6fcf681dfc.tar.zst gsoc2013-epiphany-b573119b1338722ba9f6016b72064f6fcf681dfc.zip |
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
Diffstat (limited to 'src/ephy-find-toolbar.c')
-rw-r--r-- | 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 71f255258..196957de1 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); } |