diff options
author | Eric Butler <eric@extremeboredom.net> | 2006-12-18 03:17:36 +0800 |
---|---|---|
committer | Christian Persch <chpe@src.gnome.org> | 2006-12-18 03:17:36 +0800 |
commit | f509a34254a254348465dbe018c6ee9db081193e (patch) | |
tree | f6ce0dbc582fa603779bf6fc055a876f9b082bf3 | |
parent | 25a74360022714d8dcb51b1c306069255da92079 (diff) | |
download | gsoc2013-epiphany-f509a34254a254348465dbe018c6ee9db081193e.tar gsoc2013-epiphany-f509a34254a254348465dbe018c6ee9db081193e.tar.gz gsoc2013-epiphany-f509a34254a254348465dbe018c6ee9db081193e.tar.bz2 gsoc2013-epiphany-f509a34254a254348465dbe018c6ee9db081193e.tar.lz gsoc2013-epiphany-f509a34254a254348465dbe018c6ee9db081193e.tar.xz gsoc2013-epiphany-f509a34254a254348465dbe018c6ee9db081193e.tar.zst gsoc2013-epiphany-f509a34254a254348465dbe018c6ee9db081193e.zip |
Add search_link entry to _EphyEmbedIface
2006-12-17 Eric Butler <eric@extremeboredom.net>
* src/ephy-embed.h:
Add search_link entry to _EphyEmbedIface
* src/ephy-embed.c:
Add ge-search-link signal
* embed/mozilla/EphyBrowser.cs:
Fire ge-search-link signal for opensearch tags
-rw-r--r-- | ChangeLog | 12 | ||||
-rw-r--r-- | embed/ephy-embed.c | 22 | ||||
-rw-r--r-- | embed/ephy-embed.h | 4 | ||||
-rw-r--r-- | embed/mozilla/EphyBrowser.cpp | 33 |
4 files changed, 71 insertions, 0 deletions
@@ -1,3 +1,15 @@ +2006-12-17 Eric Butler <eric@extremeboredom.net> + + * src/ephy-embed.h: + + Add search_link entry to _EphyEmbedIface + + * src/ephy-embed.c: + Add ge-search-link signal + + * embed/mozilla/EphyBrowser.cs: + Fire ge-search-link signal for opensearch tags + 2006-12-17 Christian Persch <chpe@cvs.gnome.org> * src/ephy-history-window.c: (cmd_delete): diff --git a/embed/ephy-embed.c b/embed/ephy-embed.c index 4cc5d7f30..53f3ce3cd 100644 --- a/embed/ephy-embed.c +++ b/embed/ephy-embed.c @@ -132,6 +132,28 @@ ephy_embed_base_init (gpointer g_class) 1, G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE); /** + * EphyEmbed::ge-search-link: + * @embed: + * @type: the mime-type of the search description + * @title: the title of the news feed + * @address: the URL to @embed's web site's search description + * + * The ::ge_rss signal is emitted when @embed discovers that a search + * description is available for the site it is visiting. + **/ + g_signal_new ("ge_search_link", + EPHY_TYPE_EMBED, + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (EphyEmbedIface, search_link), + NULL, NULL, + ephy_marshal_VOID__STRING_STRING_STRING, + G_TYPE_NONE, + 3, + G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE, + G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE, + G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE); + +/** * EphyEmbed::ge-feed-link: * @embed: * @type: the mime-type of the news feed diff --git a/embed/ephy-embed.h b/embed/ephy-embed.h index 90743ded7..54362404f 100644 --- a/embed/ephy-embed.h +++ b/embed/ephy-embed.h @@ -127,6 +127,10 @@ struct _EphyEmbedIface const char *type, const char *title, const char *address); + void (* search_link) (EphyEmbed *embed, + const char *type, + const char *title, + const char *address); void (* location) (EphyEmbed *embed, const char *location); void (* net_state) (EphyEmbed *embed, diff --git a/embed/mozilla/EphyBrowser.cpp b/embed/mozilla/EphyBrowser.cpp index aba1645eb..a233279a3 100644 --- a/embed/mozilla/EphyBrowser.cpp +++ b/embed/mozilla/EphyBrowser.cpp @@ -221,6 +221,39 @@ EphyDOMLinkEventListener::HandleEvent (nsIDOMEvent* aDOMEvent) /* ok, we accept this as a valid favicon for this site */ g_signal_emit_by_name (mOwner->mEmbed, "ge_favicon", spec.get()); } + else if (g_ascii_strcasecmp (rel.get (), "search") == 0) + { + linkElement->GetAttribute (NS_LITERAL_STRING ("type"), value); + + nsCString cTypeVal; + NS_UTF16ToCString (value, NS_CSTRING_ENCODING_UTF8, cTypeVal); + + if (g_ascii_strcasecmp (cTypeVal.get (), + "application/opensearchdescription+xml") == 0) + { + rv = linkElement->GetAttribute (NS_LITERAL_STRING ("href"), value); + if (NS_FAILED (rv) || !value.Length()) return NS_ERROR_FAILURE; + + nsCString cLink; + NS_UTF16ToCString (value, NS_CSTRING_ENCODING_UTF8, cLink); + + nsCOMPtr<nsIURI> docUri; + rv = GetDocURI (linkElement, getter_AddRefs (docUri)); + NS_ENSURE_TRUE (NS_SUCCEEDED (rv) && docUri, NS_ERROR_FAILURE); + + nsCString resolvedLink; + rv = docUri->Resolve (cLink, resolvedLink); + NS_ENSURE_SUCCESS (rv, NS_ERROR_FAILURE); + + linkElement->GetAttribute (NS_LITERAL_STRING ("title"), value); + + nsCString cTitle; + NS_UTF16ToCString (value, NS_CSTRING_ENCODING_UTF8, cTitle); + + g_signal_emit_by_name (mOwner->mEmbed, "ge_search_link", + cTypeVal.get(), cTitle.get(), resolvedLink.get()); + } + } else if (g_ascii_strcasecmp (rel.get (), "alternate") == 0) { linkElement->GetAttribute (NS_LITERAL_STRING ("type"), value); |