diff options
author | Xan Lopez <xan@gnome.org> | 2009-12-25 17:03:09 +0100 |
---|---|---|
committer | Xan Lopez <xan@gnome.org> | 2009-12-25 17:03:09 +0100 |
commit | 0b844bedb99264ae3699fb6a6aafa5e716b8c5ac (patch) | |
tree | 4a87b4fb6c3335703dc44a92626f3c5a16aa152c | |
parent | 319c95b59b0838a54a1ee8d52c52b47bdd0e4c2b (diff) | |
download | epiphany-0b844bedb99264ae3699fb6a6aafa5e716b8c5ac.tar.gz |
Reimplement window.close
We consider all windows opened by the web page without user
intervention as popups, and allow them to be closed in the same way if
the page so requests.
Bug #599009
-rw-r--r-- | embed/ephy-web-view.c | 18 | ||||
-rw-r--r-- | src/ephy-shell.c | 1 | ||||
-rw-r--r-- | src/ephy-window.c | 24 |
3 files changed, 30 insertions, 13 deletions
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c index 1a9ce6439..6b717a061 100644 --- a/embed/ephy-web-view.c +++ b/embed/ephy-web-view.c @@ -1943,6 +1943,20 @@ load_status_cb (WebKitWebView *web_view, } } +static gboolean +close_web_view_cb (WebKitWebView *web_view, + gpointer user_data) +{ + EphyEmbedContainer *window; + GtkWidget *widget = gtk_widget_get_toplevel (GTK_WIDGET (web_view)); + window = EPHY_EMBED_CONTAINER (widget); + + if (ephy_embed_container_get_is_popup (window)) + gtk_widget_destroy (GTK_WIDGET (window)); + + return TRUE; +} + static void ephy_web_view_init (EphyWebView *web_view) { @@ -1978,6 +1992,10 @@ ephy_web_view_init (EphyWebView *web_view) G_CALLBACK (load_status_cb), NULL); + g_signal_connect (web_view, "close-web-view", + G_CALLBACK (close_web_view_cb), + NULL); + g_signal_connect_object (web_view, "icon-loaded", G_CALLBACK (favicon_cb), web_view, (GConnectFlags)0); diff --git a/src/ephy-shell.c b/src/ephy-shell.c index c3551f861..e75030e9a 100644 --- a/src/ephy-shell.c +++ b/src/ephy-shell.c @@ -445,7 +445,6 @@ ephy_shell_new_tab_full (EphyShell *shell, if (flags & EPHY_NEW_TAB_IN_EXISTING_WINDOW) in_new_window = FALSE; in_new_window = in_new_window && !eel_gconf_get_boolean (CONF_LOCKDOWN_FULLSCREEN); - g_return_val_if_fail (in_new_window || !is_popup, NULL); g_return_val_if_fail (open_page == (gboolean)(request != NULL), NULL); jump_to = (flags & EPHY_NEW_TAB_JUMP) != 0; diff --git a/src/ephy-window.c b/src/ephy-window.c index 91b163ed1..4d339ca83 100644 --- a/src/ephy-window.c +++ b/src/ephy-window.c @@ -2434,6 +2434,17 @@ ephy_window_visibility_cb (EphyEmbed *embed, GParamSpec *pspec, EphyWindow *wind gtk_widget_hide (GTK_WIDGET (window)); } +static void +ephy_window_set_is_popup (EphyWindow *window, + gboolean is_popup) +{ + EphyWindowPrivate *priv = window->priv; + + priv->is_popup = is_popup; + + g_object_notify (G_OBJECT (window), "is-popup"); +} + static gboolean web_view_ready_cb (WebKitWebView *web_view, gpointer user_data) @@ -2519,7 +2530,7 @@ create_web_view_cb (WebKitWebView *web_view, NULL, NULL, flags, EPHY_WEB_VIEW_CHROME_ALL, - FALSE, + TRUE, /* is popup? */ 0); using_new_window = parent_window == NULL; @@ -3255,17 +3266,6 @@ ephy_window_set_chrome (EphyWindow *window, EphyWebViewChrome mask) } static void -ephy_window_set_is_popup (EphyWindow *window, - gboolean is_popup) -{ - EphyWindowPrivate *priv = window->priv; - - priv->is_popup = is_popup; - - g_object_notify (G_OBJECT (window), "is-popup"); -} - -static void ephy_window_dispose (GObject *object) { EphyWindow *window = EPHY_WINDOW (object); |