diff options
author | Benjamin Otte <otte@gnome.org> | 2009-08-14 20:13:36 +0800 |
---|---|---|
committer | Benjamin Otte <otte@gnome.org> | 2009-08-15 05:10:24 +0800 |
commit | da1f3cfc5bc93471642bd6b970ea87e663ba1d6c (patch) | |
tree | 101da7227ba4fbeb208ed3ab5ad8c6fae28f7eb0 /src/ephy-find-toolbar.c | |
parent | 32a399be40bb62174bf52209825e1ab65483b160 (diff) | |
download | gsoc2013-epiphany-da1f3cfc5bc93471642bd6b970ea87e663ba1d6c.tar gsoc2013-epiphany-da1f3cfc5bc93471642bd6b970ea87e663ba1d6c.tar.gz gsoc2013-epiphany-da1f3cfc5bc93471642bd6b970ea87e663ba1d6c.tar.bz2 gsoc2013-epiphany-da1f3cfc5bc93471642bd6b970ea87e663ba1d6c.tar.lz gsoc2013-epiphany-da1f3cfc5bc93471642bd6b970ea87e663ba1d6c.tar.xz gsoc2013-epiphany-da1f3cfc5bc93471642bd6b970ea87e663ba1d6c.tar.zst gsoc2013-epiphany-da1f3cfc5bc93471642bd6b970ea87e663ba1d6c.zip |
Don't pass the string to find to all functions
The string to find is set in the private structure, so when it needs to
be changed, change it there.
Removes lots of unnecessary code, in particular when entering text, the
marking code (that took lots of CPU) wasn't run twice.
Diffstat (limited to 'src/ephy-find-toolbar.c')
-rw-r--r-- | src/ephy-find-toolbar.c | 43 |
1 files changed, 12 insertions, 31 deletions
diff --git a/src/ephy-find-toolbar.c b/src/ephy-find-toolbar.c index 1bd2e3d25..3513235a3 100644 --- a/src/ephy-find-toolbar.c +++ b/src/ephy-find-toolbar.c @@ -227,25 +227,20 @@ find_prev_cb (EphyFindToolbar *toolbar) } static void -ephy_find_toolbar_set_properties (EphyFindToolbar *toolbar, - const char *find_string) +ephy_find_toolbar_set_properties (EphyFindToolbar *toolbar) { EphyFindToolbarPrivate *priv = toolbar->priv; WebKitWebView *web_view = priv->web_view; gboolean case_sensitive; - if (g_strcmp0 (priv->find_string, find_string) != 0) { - g_free (priv->find_string); - priv->find_string = g_strdup (find_string); - } - case_sensitive = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->case_sensitive)); webkit_web_view_unmark_text_matches (web_view); - webkit_web_view_mark_text_matches (web_view, - priv->find_string, - case_sensitive, - 0); + if (priv->find_string != NULL && priv->find_string[0] != '\0') + webkit_web_view_mark_text_matches (web_view, + priv->find_string, + case_sensitive, + 0); webkit_web_view_set_highlight_text_matches (web_view, TRUE); } @@ -275,31 +270,19 @@ real_find (EphyFindToolbarPrivate *priv, return EPHY_FIND_FOUND; } -static EphyEmbedFindResult -ephy_find_toolbar_find (EphyFindToolbar *toolbar, - const char *find_string, - gboolean links_only) -{ - EphyFindToolbarPrivate *priv = toolbar->priv; - - ephy_find_toolbar_set_properties (toolbar, find_string); - - return real_find (priv, TRUE); -} - static void entry_changed_cb (GtkEntry *entry, EphyFindToolbar *toolbar) { EphyFindToolbarPrivate *priv = toolbar->priv; - const char *text; EphyEmbedFindResult result; - text = gtk_entry_get_text (GTK_ENTRY (priv->entry)); + g_free (priv->find_string); + priv->find_string = g_strdup (gtk_entry_get_text (GTK_ENTRY (priv->entry))); - ephy_find_toolbar_set_properties (toolbar, text); - result = ephy_find_toolbar_find (toolbar, text, priv->links_only); + ephy_find_toolbar_set_properties (toolbar); + result = real_find (priv, TRUE); set_status (toolbar, result); } @@ -401,12 +384,9 @@ static void case_sensitive_toggled_cb (GtkWidget *check, EphyFindToolbar *toolbar) { - EphyFindToolbarPrivate *priv = toolbar->priv; - const char *text; gboolean case_sensitive; GtkWidget *proxy; - text = gtk_entry_get_text (GTK_ENTRY (priv->entry)); case_sensitive = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check)); proxy = gtk_tool_item_get_proxy_menu_item (GTK_TOOL_ITEM (gtk_widget_get_parent (check)), @@ -423,7 +403,7 @@ case_sensitive_toggled_cb (GtkWidget *check, (proxy, G_CALLBACK (case_sensitive_menu_toggled_cb), toolbar); } - ephy_find_toolbar_set_properties (toolbar, text); + ephy_find_toolbar_set_properties (toolbar); } static gboolean @@ -650,6 +630,7 @@ ephy_find_toolbar_finalize (GObject *o) EphyFindToolbarPrivate *priv = EPHY_FIND_TOOLBAR (o)->priv; g_free (priv->find_string); + G_OBJECT_CLASS (ephy_find_toolbar_parent_class)->finalize (o); } |