diff options
author | Christian Persch <chpe@cvs.gnome.org> | 2005-12-05 05:52:05 +0800 |
---|---|---|
committer | Christian Persch <chpe@src.gnome.org> | 2005-12-05 05:52:05 +0800 |
commit | 45def779c085277b160b016d0fa75004a82f8439 (patch) | |
tree | e40444720e42a02cd0812f2096a8d283d9b2d6d8 /embed/mozilla/EphyFind.cpp | |
parent | da002ee07fd517b377656ca1ddf86cb122881e0a (diff) | |
download | gsoc2013-epiphany-45def779c085277b160b016d0fa75004a82f8439.tar gsoc2013-epiphany-45def779c085277b160b016d0fa75004a82f8439.tar.gz gsoc2013-epiphany-45def779c085277b160b016d0fa75004a82f8439.tar.bz2 gsoc2013-epiphany-45def779c085277b160b016d0fa75004a82f8439.tar.lz gsoc2013-epiphany-45def779c085277b160b016d0fa75004a82f8439.tar.xz gsoc2013-epiphany-45def779c085277b160b016d0fa75004a82f8439.tar.zst gsoc2013-epiphany-45def779c085277b160b016d0fa75004a82f8439.zip |
While in find mode, set the selection colour to "attention".
2005-12-04 Christian Persch <chpe@cvs.gnome.org>
* embed/ephy-embed-find.c: (ephy_embed_find_set_selection):
* embed/ephy-embed-find.h:
* embed/mozilla/EphyFind.cpp:
* embed/mozilla/EphyFind.h:
* embed/mozilla/mozilla-embed-find.cpp:
While in find mode, set the selection colour to "attention".
* src/ephy-find-toolbar.c: (set_status), (clear_status),
(tab_search_key_press_cb), (entry_key_press_event_cb),
(entry_activate_cb), (set_focus_cb),
(ephy_find_toolbar_set_window), (ephy_find_toolbar_init),
(ephy_find_toolbar_class_init), (ephy_find_toolbar_set_embed),
(ephy_find_toolbar_open), (ephy_find_toolbar_close),
(ephy_find_toolbar_request_close):
* src/ephy-find-toolbar.h:
* src/ephy-window.c: (sync_tab_document_type),
(find_toolbar_close_cb), (ephy_window_set_print_preview),
(ephy_window_get_find_toolbar), (ephy_window_get_context_event):
Refactor find toolbar closing not to crash with auto-closing popups.
Unset the selection colour on close.
Remove dead #ifdef FIND_WHILE_TYPING_IN_EMBED code.
Diffstat (limited to 'embed/mozilla/EphyFind.cpp')
-rw-r--r-- | embed/mozilla/EphyFind.cpp | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/embed/mozilla/EphyFind.cpp b/embed/mozilla/EphyFind.cpp index c6b9b7c9b..1eab78c34 100644 --- a/embed/mozilla/EphyFind.cpp +++ b/embed/mozilla/EphyFind.cpp @@ -50,8 +50,12 @@ #include <nsIDOMHTMLAnchorElement.h> #ifdef HAVE_TYPEAHEADFIND +#include <nsISimpleEnumerator.h> #include <nsIDocShell.h> +#include <nsIDocShellTreeItem.h> #include <nsITypeAheadFind.h> +#include <nsISelectionDisplay.h> +#include <nsISelectionController.h> #else #include <nsIWebBrowserFind.h> #include <nsMemory.h> @@ -68,6 +72,9 @@ static const PRUnichar kKeyPress[] = { 'k', 'e', 'y', 'p', 'r', 'e', 's', 's', ' EphyFind::EphyFind () : mCurrentEmbed(nsnull) +#ifdef HAVE_TYPEAHEADFIND +, mAttention(PR_FALSE) +#endif { LOG ("EphyFind ctor [%p]", this); } @@ -83,6 +90,8 @@ EphyFind::SetEmbed (EphyEmbed *aEmbed) nsresult rv = NS_OK; if (aEmbed == mCurrentEmbed) return rv; + SetSelectionAttention (PR_FALSE); + mCurrentEmbed = nsnull; mWebBrowser = nsnull; @@ -147,6 +156,53 @@ EphyFind::SetFindProperties (const char *aSearchString, #endif /* TYPEAHEADFIND */ } +void +EphyFind::SetSelectionAttention (PRBool aAttention) +{ +#ifdef HAVE_TYPEAHEADFIND + if (aAttention && mAttention) return; + + mAttention = aAttention; + + nsresult rv; + nsCOMPtr<nsIDocShell> shell (do_GetInterface (mWebBrowser, &rv)); + /* It's okay for this to fail, if the tab is closing, or if + * we weren't attached to any tab yet + */ + if (NS_FAILED (rv) || !shell) return; + + nsCOMPtr<nsISimpleEnumerator> enumerator; + rv = shell->GetDocShellEnumerator (nsIDocShellTreeItem::typeContent, + nsIDocShell::ENUMERATE_FORWARDS, + getter_AddRefs (enumerator)); + NS_ENSURE_SUCCESS (rv, ); + + PRInt16 display; + if (aAttention) { + display = nsISelectionController::SELECTION_ATTENTION; + } else { + display = nsISelectionController::SELECTION_ON; + } + + PRBool hasMore = PR_FALSE; + while (NS_SUCCEEDED (enumerator->HasMoreElements (&hasMore)) && hasMore) { + nsCOMPtr<nsISupports> element; + nsCOMPtr<nsISelectionDisplay> sd; + + enumerator->GetNext (getter_AddRefs (element)); + if (!element) continue; + + sd = do_GetInterface (element); + if (!sd) continue; + + nsCOMPtr<nsISelectionController> controller (do_QueryInterface (sd)); + if (!controller) continue; + + controller->SetDisplaySelection (display); + } +#endif +} + EphyEmbedFindResult EphyFind::Find (const char *aSearchString, PRBool aLinksOnly) @@ -158,6 +214,8 @@ EphyFind::Find (const char *aSearchString, NS_CSTRING_ENCODING_UTF8, uSearchString); #ifdef HAVE_TYPEAHEADFIND + SetSelectionAttention (PR_TRUE); + nsresult rv; PRUint16 found = nsITypeAheadFind::FIND_NOTFOUND; rv = mFinder->Find (uSearchString, aLinksOnly, &found); @@ -182,6 +240,8 @@ EphyFind::FindAgain (PRBool aForward) if (!mFinder) return EPHY_EMBED_FIND_NOTFOUND; #ifdef HAVE_TYPEAHEADFIND + SetSelectionAttention (PR_TRUE); + nsresult rv; PRUint16 found = nsITypeAheadFind::FIND_NOTFOUND; if (aForward) { |