From 45def779c085277b160b016d0fa75004a82f8439 Mon Sep 17 00:00:00 2001 From: Christian Persch Date: Sun, 4 Dec 2005 21:52:05 +0000 Subject: While in find mode, set the selection colour to "attention". 2005-12-04 Christian Persch * 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. --- embed/mozilla/EphyFind.cpp | 60 ++++++++++++++++++++++++++++++++++++ embed/mozilla/EphyFind.h | 3 +- embed/mozilla/mozilla-embed-find.cpp | 11 +++++++ 3 files changed, 73 insertions(+), 1 deletion(-) (limited to 'embed/mozilla') 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 #ifdef HAVE_TYPEAHEADFIND +#include #include +#include #include +#include +#include #else #include #include @@ -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 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 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 element; + nsCOMPtr sd; + + enumerator->GetNext (getter_AddRefs (element)); + if (!element) continue; + + sd = do_GetInterface (element); + if (!sd) continue; + + nsCOMPtr 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) { diff --git a/embed/mozilla/EphyFind.h b/embed/mozilla/EphyFind.h index d5dd8e239..d2a636df8 100644 --- a/embed/mozilla/EphyFind.h +++ b/embed/mozilla/EphyFind.h @@ -40,7 +40,7 @@ class EphyFind nsresult SetEmbed (EphyEmbed *aEmbed); void SetFindProperties (const char *aSearchString, PRBool aCaseSensitive); - + void SetSelectionAttention (PRBool aAttention); EphyEmbedFindResult Find (const char *aSearchString, PRBool aLinksOnly); EphyEmbedFindResult FindAgain (PRBool aForward); @@ -53,6 +53,7 @@ class EphyFind #ifdef HAVE_TYPEAHEADFIND nsCOMPtr mFinder; + PRBool mAttention; #else nsCOMPtr mFinder; #endif diff --git a/embed/mozilla/mozilla-embed-find.cpp b/embed/mozilla/mozilla-embed-find.cpp index 3026a3934..1c057f577 100644 --- a/embed/mozilla/mozilla-embed-find.cpp +++ b/embed/mozilla/mozilla-embed-find.cpp @@ -83,6 +83,16 @@ impl_find_again (EphyEmbedFind *efind, return priv->find->FindAgain (forward); } +static void +impl_set_selection (EphyEmbedFind *efind, + gboolean attention) +{ + MozillaEmbedFind *find = MOZILLA_EMBED_FIND (efind); + MozillaEmbedFindPrivate *priv = find->priv; + + priv->find->SetSelectionAttention (attention); +} + static gboolean impl_activate_link (EphyEmbedFind *efind, GdkModifierType mask) @@ -100,6 +110,7 @@ ephy_find_iface_init (EphyEmbedFindIface *iface) iface->set_properties = impl_set_properties; iface->find = impl_find; iface->find_again = impl_find_again; + iface->set_selection = impl_set_selection; iface->activate_link = impl_activate_link; } -- cgit v1.2.3