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 | |
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')
-rw-r--r-- | embed/ephy-embed-find.c | 8 | ||||
-rw-r--r-- | embed/ephy-embed-find.h | 5 | ||||
-rw-r--r-- | embed/mozilla/EphyFind.cpp | 60 | ||||
-rw-r--r-- | embed/mozilla/EphyFind.h | 3 | ||||
-rw-r--r-- | embed/mozilla/mozilla-embed-find.cpp | 11 |
5 files changed, 86 insertions, 1 deletions
diff --git a/embed/ephy-embed-find.c b/embed/ephy-embed-find.c index 80ef28b18..7fd05d51a 100644 --- a/embed/ephy-embed-find.c +++ b/embed/ephy-embed-find.c @@ -78,6 +78,14 @@ ephy_embed_find_find_again (EphyEmbedFind *find, return iface->find_again (find, forward); } +void +ephy_embed_find_set_selection (EphyEmbedFind *find, + gboolean attention) +{ + EphyEmbedFindIface *iface = EPHY_EMBED_FIND_GET_IFACE (find); + iface->set_selection (find, attention); +} + /** * ephy_embed_find_activate_link: * @embed: an #EphyEmbedFind diff --git a/embed/ephy-embed-find.h b/embed/ephy-embed-find.h index 0370e8c6c..decc96737 100644 --- a/embed/ephy-embed-find.h +++ b/embed/ephy-embed-find.h @@ -62,6 +62,8 @@ struct _EphyEmbedFindIface gboolean links_only); EphyEmbedFindResult (* find_again) (EphyEmbedFind *find, gboolean forward); + void (* set_selection) (EphyEmbedFind *find, + gboolean attention); gboolean (* activate_link) (EphyEmbedFind *find, GdkModifierType mask); }; @@ -82,6 +84,9 @@ EphyEmbedFindResult ephy_embed_find_find (EphyEmbedFind *find, EphyEmbedFindResult ephy_embed_find_find_again (EphyEmbedFind *find, gboolean forward); +void ephy_embed_find_set_selection (EphyEmbedFind *find, + gboolean attention); + gboolean ephy_embed_find_activate_link (EphyEmbedFind *find, GdkModifierType mask); 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) { 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<nsITypeAheadFind> mFinder; + PRBool mAttention; #else nsCOMPtr<nsIWebBrowserFind> 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; } |