diff options
-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); } |