[Sugar-devel] [PATCH browse] Highlight the search results correctly

Manuel Quiñones manuq at laptop.org
Mon Jan 23 09:33:18 EST 2012


El día 12 de enero de 2012 07:30, Simon Schampijer
<simon at schampijer.de> escribió:
> Inspired by the Epiphany code we now highlight the
> search results in the default color, yellow.

Using the webkit API correctly, great.

I got an unexpected behaviour if I go back and forward the page
history:  the highlight uses different, gray, colors.  The same
happens in Epiphany.  But I'm fine pushing as is.

Acked-by: Manuel Quiñones <manuq at laptop.org>

> Signed-off-by: Simon Schampijer <simon at laptop.org>
> ---
>  edittoolbar.py |   18 ++++++++++++------
>  1 files changed, 12 insertions(+), 6 deletions(-)
>
> diff --git a/edittoolbar.py b/edittoolbar.py
> index 958b6ad..f77cbbe 100644
> --- a/edittoolbar.py
> +++ b/edittoolbar.py
> @@ -123,15 +123,21 @@ class EditToolbar(BaseEditToolbar):
>     def __paste_cb(self, button):
>         self._browser.paste_clipboard()
>
> -    def __search_entry_activate_cb(self, entry):
> -        search_text = entry.get_text()
> -        self._browser.search_text(search_text, case_sensitive=False,
> -                                  forward=True, wrap=True)
> -
> -    def __search_entry_changed_cb(self, entry):
> +    def _find_and_mark_text(self, entry):
>         search_text = entry.get_text()
> +        self._browser.unmark_text_matches()
> +        self._browser.mark_text_matches(search_text, case_sensitive=False,
> +                                        limit=0)
> +        self._browser.set_highlight_text_matches(True)
>         found = self._browser.search_text(search_text, case_sensitive=False,
>                                           forward=True, wrap=True)
> +        return found
> +
> +    def __search_entry_activate_cb(self, entry):
> +        self._find_and_mark_text(entry)
> +
> +    def __search_entry_changed_cb(self, entry):
> +        found = self._find_and_mark_text(entry)
>         if not found:
>             self._prev.props.sensitive = False
>             self._next.props.sensitive = False
> --
> 1.7.7.5
>
> _______________________________________________
> Sugar-devel mailing list
> Sugar-devel at lists.sugarlabs.org
> http://lists.sugarlabs.org/listinfo/sugar-devel



-- 
.. manuq ..


More information about the Sugar-devel mailing list