From 861720c0698e978b8278ab17f003c297f44beff4 Mon Sep 17 00:00:00 2001 From: Xan Lopez Date: Sun, 17 Feb 2008 18:20:39 +0000 Subject: Add ephy-embed::new-document-now signal, does the same than old ge-content-change (used by adblock extension). Part of #502283 svn path=/trunk/; revision=7959 --- doc/reference/tmpl/ephy-embed.sgml | 5 +++++ embed/ephy-embed.c | 20 ++++++++++++++++++++ embed/ephy-embed.h | 3 +++ embed/mozilla/mozilla-embed.cpp | 1 + embed/webkit/webkit-embed.c | 4 ++++ 5 files changed, 33 insertions(+) diff --git a/doc/reference/tmpl/ephy-embed.sgml b/doc/reference/tmpl/ephy-embed.sgml index a1d6a3384..42e21f5a9 100644 --- a/doc/reference/tmpl/ephy-embed.sgml +++ b/doc/reference/tmpl/ephy-embed.sgml @@ -150,6 +150,11 @@ be done by casting). + + + + + @ephyembed: the object which received the signal. @: @: diff --git a/embed/ephy-embed.c b/embed/ephy-embed.c index 267b353fc..98f9d30b5 100644 --- a/embed/ephy-embed.c +++ b/embed/ephy-embed.c @@ -345,6 +345,26 @@ ephy_embed_base_init (gpointer g_class) G_TYPE_NONE, 1, G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE); +/** + * EphyEmbed::new-document-now: + * @embed: + * @uri: URI of the new content + * + * The ::new-document-now signal is emitted when a new page content + * is being loaded into the browser. It's a good place to do view + * related changes, for example to restore the zoom level of a page + * or to set an user style sheet. + **/ + g_signal_new ("new-document-now", + EPHY_TYPE_EMBED, + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (EphyEmbedIface, new_document_now), + NULL, NULL, + g_cclosure_marshal_VOID__STRING, + G_TYPE_NONE, + 1, + G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE); + initialized = TRUE; } diff --git a/embed/ephy-embed.h b/embed/ephy-embed.h index 560a2f9cd..ed3934c8f 100644 --- a/embed/ephy-embed.h +++ b/embed/ephy-embed.h @@ -156,6 +156,9 @@ struct _EphyEmbedIface GdkEventKey *event); gboolean (* close_request) (EphyEmbed *embed); + void (* new_document_now) (EphyEmbed *embed, + const char *uri); + /* Methods */ void (* load_url) (EphyEmbed *embed, const char *url); diff --git a/embed/mozilla/mozilla-embed.cpp b/embed/mozilla/mozilla-embed.cpp index 77d11b224..dfa3c23a1 100644 --- a/embed/mozilla/mozilla-embed.cpp +++ b/embed/mozilla/mozilla-embed.cpp @@ -970,6 +970,7 @@ update_load_state (MozillaEmbed *membed, gint state) char *address; address = gtk_moz_embed_get_location (moz_embed); + g_signal_emit_by_name (membed, "new-document-now", address); ephy_base_embed_popups_manager_reset (EPHY_BASE_EMBED (membed)); ephy_base_embed_restore_zoom_level (EPHY_BASE_EMBED (membed), address); g_free (address); diff --git a/embed/webkit/webkit-embed.c b/embed/webkit/webkit-embed.c index 6447f91b9..5a8546ae5 100644 --- a/embed/webkit/webkit-embed.c +++ b/embed/webkit/webkit-embed.c @@ -181,12 +181,16 @@ update_load_state (WebKitEmbed *embed, WebKitWebView *web_view) EphyEmbedNetState estate = EPHY_EMBED_STATE_UNKNOWN; if (embed->priv->load_state == WEBKIT_EMBED_LOAD_STARTED) + { estate = (EphyEmbedNetState) (estate | EPHY_EMBED_STATE_START | EPHY_EMBED_STATE_NEGOTIATING | EPHY_EMBED_STATE_IS_REQUEST | EPHY_EMBED_STATE_IS_NETWORK); + g_signal_emit_by_name (embed, "new-document-now", embed->priv->loading_uri); + } + if (embed->priv->load_state == WEBKIT_EMBED_LOAD_LOADING) estate = (EphyEmbedNetState) (estate | EPHY_EMBED_STATE_TRANSFERRING | -- cgit v1.2.3