aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAdam Hooper <adamh@src.gnome.org>2004-07-01 09:47:17 +0800
committerAdam Hooper <adamh@src.gnome.org>2004-07-01 09:47:17 +0800
commitbbd9d6551d3f84f4cc7afa5ef4c21dfadceb668d (patch)
treed368c9eec18379a062af184d89b064517273c558 /src
parent61533f01f0f6df3b9dafc18d1567507830db0752 (diff)
downloadgsoc2013-epiphany-bbd9d6551d3f84f4cc7afa5ef4c21dfadceb668d.tar
gsoc2013-epiphany-bbd9d6551d3f84f4cc7afa5ef4c21dfadceb668d.tar.gz
gsoc2013-epiphany-bbd9d6551d3f84f4cc7afa5ef4c21dfadceb668d.tar.bz2
gsoc2013-epiphany-bbd9d6551d3f84f4cc7afa5ef4c21dfadceb668d.tar.lz
gsoc2013-epiphany-bbd9d6551d3f84f4cc7afa5ef4c21dfadceb668d.tar.xz
gsoc2013-epiphany-bbd9d6551d3f84f4cc7afa5ef4c21dfadceb668d.tar.zst
gsoc2013-epiphany-bbd9d6551d3f84f4cc7afa5ef4c21dfadceb668d.zip
Popup blocking support. View -> Popup Windows.
Diffstat (limited to 'src')
-rwxr-xr-xsrc/ephy-statusbar.c62
-rw-r--r--src/ephy-statusbar.h5
-rw-r--r--src/ephy-tab.c324
-rw-r--r--src/ephy-window.c137
4 files changed, 526 insertions, 2 deletions
diff --git a/src/ephy-statusbar.c b/src/ephy-statusbar.c
index 1e8d22259..8e2e8c475 100755
--- a/src/ephy-statusbar.c
+++ b/src/ephy-statusbar.c
@@ -50,6 +50,8 @@ struct EphyStatusbarPrivate
GtkWidget *security_icon;
GtkWidget *progressbar;
GtkWidget *security_evbox;
+ GtkWidget *popups_manager_icon;
+ GtkWidget *popups_manager_evbox;
};
GType
@@ -118,6 +120,36 @@ create_statusbar_security_icon (EphyStatusbar *s)
}
static void
+create_statusbar_popups_manager_icon (EphyStatusbar *s)
+{
+ s->popups_manager_frame = gtk_frame_new (NULL);
+ gtk_frame_set_shadow_type (GTK_FRAME (s->popups_manager_frame),
+ GTK_SHADOW_IN);
+
+ s->priv->popups_manager_icon = gtk_image_new_from_stock
+ (EPHY_STOCK_POPUPS, GTK_ICON_SIZE_MENU);
+
+ s->priv->popups_manager_evbox = gtk_event_box_new ();
+
+ gtk_event_box_set_visible_window
+ (GTK_EVENT_BOX (s->priv->popups_manager_evbox), FALSE);
+
+ gtk_container_add (GTK_CONTAINER (s->popups_manager_frame),
+ GTK_WIDGET (s->priv->popups_manager_evbox));
+ gtk_container_add (GTK_CONTAINER (s->priv->popups_manager_evbox),
+ GTK_WIDGET (s->priv->popups_manager_icon));
+
+ gtk_widget_show (s->priv->popups_manager_evbox);
+ gtk_widget_show (s->priv->popups_manager_icon);
+
+ /* note lack of gtk_widget_show (s->popups_manager_frame); */
+
+ gtk_box_pack_start (GTK_BOX (s->priv->icon_container),
+ GTK_WIDGET (s->popups_manager_frame),
+ FALSE, TRUE, 0);
+}
+
+static void
create_statusbar_progress (EphyStatusbar *s)
{
s->priv->progressbar = gtk_progress_bar_new ();
@@ -170,6 +202,7 @@ ephy_statusbar_init (EphyStatusbar *t)
create_statusbar_progress (t);
create_statusbar_security_icon (t);
+ create_statusbar_popups_manager_icon (t);
/* FIXME: is this the right way ? */
sync_shadow_type (t, NULL, NULL);
@@ -202,7 +235,7 @@ ephy_statusbar_new (void)
/**
* ephy_statusbar_set_security_state:
- * @statusbar: a #EphyStatusbar
+ * @statusbar: an #EphyStatusbar
* @secure: whether to set the icon to show secure or insecure
* @tooltip: a string detailing the security state
*
@@ -225,6 +258,33 @@ ephy_statusbar_set_security_state (EphyStatusbar *statusbar,
}
/**
+ * ephy_statusbar_set_popups_state:
+ * @statusbar: an #EphyStatusbar
+ * @hidden: %TRUE if popups have been hidden
+ * @tooltip: a string to display as tooltip, or %NULL
+ *
+ * Sets the statusbar's popup-blocker icon's tooltip and visibility.
+ **/
+void
+ephy_statusbar_set_popups_state (EphyStatusbar *statusbar,
+ gboolean hidden,
+ const char *tooltip)
+{
+ if (hidden)
+ {
+ gtk_widget_hide (statusbar->popups_manager_frame);
+ }
+ else
+ {
+ gtk_tooltips_set_tip (statusbar->tooltips,
+ statusbar->priv->popups_manager_evbox,
+ tooltip, NULL);
+
+ gtk_widget_show (statusbar->popups_manager_frame);
+ }
+}
+
+/**
* ephy_statusbar_set_progress:
* @statusbar: a #EphyStatusbar
* @progress: the progress as an integer between 0 and 100 per cent.
diff --git a/src/ephy-statusbar.h b/src/ephy-statusbar.h
index ed6c44844..8ca1b5af4 100644
--- a/src/ephy-statusbar.h
+++ b/src/ephy-statusbar.h
@@ -46,6 +46,7 @@ struct EphyStatusbar
/*< public >*/
GtkTooltips *tooltips;
GtkWidget *security_frame;
+ GtkWidget *popups_manager_frame;
/*< private >*/
EphyStatusbarPrivate *priv;
@@ -64,6 +65,10 @@ void ephy_statusbar_set_security_state (EphyStatusbar *statusbar,
gboolean secure,
const char *tooltip);
+void ephy_statusbar_set_popups_state (EphyStatusbar *statusbar,
+ gboolean hidden,
+ const char *tooltip);
+
void ephy_statusbar_set_progress (EphyStatusbar *statusbar,
int progress);
diff --git a/src/ephy-tab.c b/src/ephy-tab.c
index 33fd8ea01..a55759d89 100644
--- a/src/ephy-tab.c
+++ b/src/ephy-tab.c
@@ -2,6 +2,7 @@
* Copyright (C) 2000-2003 Marco Pesenti Gritti
* Copyright (C) 2003, 2004 Christian Persch
* Copyright (C) 2004 Crispin Flowerday
+ * Copyright (C) 2004 Adam Hooper
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -38,7 +39,9 @@
#include "ephy-embed-persist.h"
#include "ephy-history.h"
#include "ephy-embed-shell.h"
+#include "ephy-embed-single.h"
#include "ephy-shell.h"
+#include "ephy-permission-manager.h"
#include <glib/gi18n.h>
#include <libgnomevfs/gnome-vfs-uri.h>
@@ -81,6 +84,8 @@ struct EphyTabPrivate
float zoom;
gboolean setting_zoom;
EmbedSecurityLevel security_level;
+ GSList *hidden_popups;
+ GSList *shown_popups;
TabNavigationFlags nav_flags;
};
@@ -98,11 +103,19 @@ enum
PROP_MESSAGE,
PROP_NAVIGATION,
PROP_SECURITY,
+ PROP_HIDDEN_POPUP_COUNT,
+ PROP_DISPLAY_POPUPS,
PROP_TITLE,
PROP_VISIBLE,
PROP_ZOOM
};
+typedef struct
+{
+ char *url;
+ char *features;
+} PopupInfo;
+
static GObjectClass *parent_class = NULL;
static gulong tab_id = 0;
@@ -125,6 +138,10 @@ static void ephy_tab_set_title (EphyTab *tab,
const char *new_title);
static void ephy_tab_set_zoom (EphyTab *tab,
float zoom);
+static guint popup_blocker_n_hidden (EphyTab *tab);
+static gboolean ephy_tab_get_popups_displayed (EphyTab *tab);
+static void ephy_tab_set_popups_displayed (EphyTab *tab,
+ gboolean allowed);
/* Class functions */
@@ -171,12 +188,17 @@ ephy_tab_set_property (GObject *object,
ephy_tab_set_location (tab, g_value_get_string (value),
TAB_ADDRESS_EXPIRE_NOW);
break;
+ case PROP_DISPLAY_POPUPS:
+ ephy_tab_set_popups_displayed
+ (tab, g_value_get_boolean (value));
+ break;
case PROP_ICON:
case PROP_LOAD_PROGRESS:
case PROP_LOAD_STATUS:
case PROP_MESSAGE:
case PROP_NAVIGATION:
case PROP_SECURITY:
+ case PROP_HIDDEN_POPUP_COUNT:
case PROP_TITLE:
case PROP_VISIBLE:
case PROP_ZOOM:
@@ -216,6 +238,13 @@ ephy_tab_get_property (GObject *object,
case PROP_SECURITY:
g_value_set_int (value, tab->priv->security_level);
break;
+ case PROP_HIDDEN_POPUP_COUNT:
+ g_value_set_int (value, popup_blocker_n_hidden (tab));
+ break;
+ case PROP_DISPLAY_POPUPS:
+ g_value_set_boolean
+ (value, ephy_tab_get_popups_displayed (tab));
+ break;
case PROP_TITLE:
g_value_set_string (value, tab->priv->title);
break;
@@ -351,6 +380,24 @@ ephy_tab_class_init (EphyTabClass *class)
G_PARAM_READABLE));
g_object_class_install_property (object_class,
+ PROP_HIDDEN_POPUP_COUNT,
+ g_param_spec_int ("hidden-popup-count",
+ "Number of Blocked Popups",
+ "The tab's number of blocked popup windows",
+ 0,
+ G_MAXINT,
+ 0,
+ G_PARAM_READABLE));
+
+ g_object_class_install_property (object_class,
+ PROP_DISPLAY_POPUPS,
+ g_param_spec_boolean ("popups-allowed",
+ "Popups Allowed",
+ "Whether popup windows are to be displayed",
+ FALSE,
+ G_PARAM_READABLE | G_PARAM_WRITABLE));
+
+ g_object_class_install_property (object_class,
PROP_TITLE,
g_param_spec_string ("title",
"Title",
@@ -380,6 +427,266 @@ ephy_tab_class_init (EphyTabClass *class)
}
static void
+popups_manager_free_info (PopupInfo *popup)
+{
+ g_free (popup->url);
+ g_free (popup->features);
+ g_free (popup);
+}
+
+static void
+popups_manager_add (EphyTab *tab,
+ const char *url,
+ const char *features)
+{
+ PopupInfo *popup;
+
+ LOG ("popups_manager_add: tab %p, url %s, features %s",
+ tab, url, features)
+
+ g_return_if_fail (EPHY_IS_TAB (tab));
+
+ popup = g_new0 (PopupInfo, 1);
+
+ popup->url = g_strdup (url);
+ popup->features = g_strdup (features);
+
+ tab->priv->hidden_popups = g_slist_prepend
+ (tab->priv->hidden_popups, popup);
+
+ g_object_notify (G_OBJECT (tab), "hidden-popup-count");
+}
+
+static gboolean
+popups_manager_remove_window (EphyTab *tab,
+ EphyWindow *window)
+{
+ tab->priv->shown_popups = g_slist_remove (tab->priv->shown_popups,
+ window);
+
+ return FALSE;
+}
+
+static void
+disconnect_popup (EphyWindow *window,
+ EphyTab *tab)
+{
+ g_signal_handlers_disconnect_by_func
+ (window, G_CALLBACK (popups_manager_remove_window), tab);
+}
+
+static void
+popups_manager_add_window (EphyTab *tab,
+ EphyWindow *window)
+{
+ LOG ("popups_manager_add_window: tab %p, window %p", tab, window)
+
+ g_return_if_fail (EPHY_IS_TAB (tab));
+ g_return_if_fail (EPHY_IS_WINDOW (window));
+
+ tab->priv->shown_popups = g_slist_prepend
+ (tab->priv->shown_popups, window);
+
+ g_signal_connect_swapped (window, "destroy",
+ G_CALLBACK (popups_manager_remove_window),
+ tab);
+}
+
+static gboolean
+ephy_tab_get_popups_displayed (EphyTab *tab)
+{
+ EphyPermissionManager *permission_manager;
+ EphyPermission response;
+ EphyEmbed *embed;
+ char *location;
+ gboolean allow;
+
+ g_return_val_if_fail (EPHY_IS_TAB (tab), FALSE);
+
+ permission_manager = EPHY_PERMISSION_MANAGER
+ (ephy_embed_shell_get_embed_single (embed_shell));
+ g_return_val_if_fail (EPHY_IS_PERMISSION_MANAGER (permission_manager),
+ FALSE);
+
+ embed = ephy_tab_get_embed (tab);
+ g_return_val_if_fail (EPHY_IS_EMBED (embed), FALSE);
+
+ location = ephy_embed_get_location (embed, TRUE);
+ if (location == NULL) return FALSE; /* FALSE, TRUE... same thing */
+
+ response = ephy_permission_manager_test
+ (permission_manager, location, EPT_POPUP);
+
+ switch (response)
+ {
+ case EPHY_PERMISSION_ALLOWED:
+ allow = TRUE;
+ break;
+ case EPHY_PERMISSION_DENIED:
+ allow = FALSE;
+ break;
+ case EPHY_PERMISSION_DEFAULT:
+ default:
+ allow = eel_gconf_get_boolean
+ (CONF_SECURITY_ALLOW_POPUPS);
+ break;
+ }
+
+ g_free (location);
+
+ LOG ("ephy_tab_get_popups_displayed: tab %p, allowed: %d", tab, allow)
+
+ return allow;
+}
+
+static void
+popups_manager_show (PopupInfo *popup,
+ EphyTab *tab)
+{
+ EphyEmbed *embed;
+ EphyEmbedSingle *single;
+
+ embed = ephy_tab_get_embed (tab);
+
+ single = EPHY_EMBED_SINGLE
+ (ephy_embed_shell_get_embed_single (embed_shell));
+
+ ephy_embed_single_open_window (single, embed, popup->url,
+ popup->features);
+
+ popups_manager_free_info (popup);
+}
+
+static void
+popups_manager_show_all (EphyTab *tab)
+{
+ LOG ("popup_blocker_show_all: tab %p", tab)
+
+ g_slist_foreach (tab->priv->hidden_popups,
+ (GFunc) popups_manager_show, tab);
+ g_slist_free (tab->priv->hidden_popups);
+ tab->priv->hidden_popups = NULL;
+
+ g_object_notify (G_OBJECT (tab), "hidden-popup-count");
+}
+
+static char *
+popups_manager_new_window_info (EphyWindow *window)
+{
+ EphyEmbedChrome chrome;
+ char *features;
+ int w, h;
+
+ g_object_get (window, "chrome", &chrome, NULL);
+ gtk_window_get_size (GTK_WINDOW (window), &w, &h);
+
+ features = g_strdup_printf
+ ("width=%d,height=%d,menubar=%d,status=%d,toolbar=%d",
+ w, h,
+ (chrome & EPHY_EMBED_CHROME_MENUBAR) > 0,
+ (chrome & EPHY_EMBED_CHROME_STATUSBAR) > 0,
+ (chrome & EPHY_EMBED_CHROME_TOOLBAR) > 0);
+
+ return features;
+}
+
+static void
+popups_manager_hide (EphyWindow *window,
+ EphyTab *parent_tab)
+{
+ EphyEmbed *embed;
+ char *location;
+ char *features;
+
+ embed = ephy_window_get_active_embed (window);
+ g_return_if_fail (EPHY_IS_EMBED (embed));
+
+ location = ephy_embed_get_location (embed, TRUE);
+ if (location == NULL) return;
+
+ features = popups_manager_new_window_info (window);
+
+ popups_manager_add (parent_tab, location, features);
+
+ gtk_widget_destroy (GTK_WIDGET (window));
+
+ g_free (location);
+ g_free (features);
+}
+
+static void
+popups_manager_hide_all (EphyTab *tab)
+{
+ LOG ("popup_blocker_hide_all: tab %p", tab)
+
+ g_slist_foreach (tab->priv->shown_popups,
+ (GFunc) popups_manager_hide, tab);
+ g_slist_free (tab->priv->shown_popups);
+ tab->priv->shown_popups = NULL;
+}
+
+static void
+ephy_tab_set_popups_displayed (EphyTab *tab,
+ gboolean allowed)
+{
+ char *location;
+ EphyEmbed *embed;
+ EphyPermissionManager *manager;
+ EphyPermission permission;
+
+ g_return_if_fail (EPHY_IS_TAB (tab));
+
+ embed = ephy_tab_get_embed (tab);
+
+ location = ephy_embed_get_location (embed, TRUE);
+ g_return_if_fail (location != NULL);
+
+ manager = EPHY_PERMISSION_MANAGER
+ (ephy_embed_shell_get_embed_single (embed_shell));
+ g_return_if_fail (EPHY_IS_PERMISSION_MANAGER (manager));
+
+ permission = allowed ? EPHY_PERMISSION_ALLOWED
+ : EPHY_PERMISSION_DENIED;
+
+ ephy_permission_manager_add (manager, location, EPT_POPUP, permission);
+
+ if (allowed)
+ {
+ popups_manager_show_all (tab);
+ }
+ else
+ {
+ popups_manager_hide_all (tab);
+ }
+
+ g_free (location);
+}
+
+static guint
+popup_blocker_n_hidden (EphyTab *tab)
+{
+ return g_slist_length (tab->priv->hidden_popups);
+}
+
+static void
+popups_manager_reset (EphyTab *tab)
+{
+ g_return_if_fail (EPHY_IS_TAB (tab));
+
+ g_slist_foreach (tab->priv->hidden_popups,
+ (GFunc) popups_manager_free_info, NULL);
+ g_slist_free (tab->priv->hidden_popups);
+ tab->priv->hidden_popups = NULL;
+
+ g_slist_foreach (tab->priv->shown_popups,
+ (GFunc) disconnect_popup, tab);
+ g_slist_free (tab->priv->shown_popups);
+ tab->priv->shown_popups = NULL;
+
+ g_object_notify (G_OBJECT (tab), "hidden-popup-count");
+}
+
+static void
ephy_tab_finalize (GObject *object)
{
EphyTab *tab = EPHY_TAB (object);
@@ -396,6 +703,7 @@ ephy_tab_finalize (GObject *object)
g_free (tab->priv->icon_address);
g_free (tab->priv->link_message);
g_free (tab->priv->status_message);
+ popups_manager_reset (tab);
G_OBJECT_CLASS (parent_class)->finalize (object);
@@ -676,6 +984,8 @@ ephy_tab_address_cb (EphyEmbed *embed, const char *address, EphyTab *tab)
ephy_tab_set_link_message (tab, NULL);
ephy_tab_set_icon_address (tab, NULL);
ephy_tab_update_navigation_flags (tab, embed);
+ popups_manager_reset (tab);
+ g_object_notify (G_OBJECT (tab), "popups-allowed");
}
static void
@@ -954,6 +1264,15 @@ ephy_tab_new_window_cb (EphyEmbed *embed, EphyEmbed **new_embed,
ephy_window_add_tab (window, new_tab, EPHY_NOTEBOOK_ADD_LAST, FALSE);
*new_embed = ephy_tab_get_embed (new_tab);
+
+ popups_manager_add_window (tab, window);
+}
+
+static void
+ephy_tab_popup_blocked_cb (EphyEmbed *embed, const char *url,
+ const char *features, EphyTab *tab)
+{
+ popups_manager_add (tab, url, features);
}
static gboolean
@@ -1230,6 +1549,8 @@ ephy_tab_init (EphyTab *tab)
tab->priv->load_status = FALSE;
tab->priv->link_message = NULL;
tab->priv->security_level = STATE_IS_UNKNOWN;
+ tab->priv->hidden_popups = NULL;
+ tab->priv->shown_popups = NULL;
tab->priv->zoom = 1.0;
tab->priv->setting_zoom = FALSE;
tab->priv->address_expire = TAB_ADDRESS_EXPIRE_NOW;
@@ -1270,6 +1591,9 @@ ephy_tab_init (EphyTab *tab)
g_signal_connect_object (embed, "ge_new_window",
G_CALLBACK (ephy_tab_new_window_cb),
tab, 0);
+ g_signal_connect_object (embed, "ge_popup_blocked",
+ G_CALLBACK (ephy_tab_popup_blocked_cb),
+ tab, 0);
g_signal_connect_object (embed, "visibility",
G_CALLBACK (ephy_tab_visibility_cb),
tab, 0);
diff --git a/src/ephy-window.c b/src/ephy-window.c
index f003a1961..b365c4f47 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -81,6 +81,8 @@ static void ephy_window_view_toolbar_cb (GtkAction *action,
EphyWindow *window);
static void ephy_window_view_bookmarksbar_cb (GtkAction *action,
EphyWindow *window);
+static void ephy_window_view_popup_windows_cb (GtkAction *action,
+ EphyWindow *window);
static GtkActionEntry ephy_menu_entries [] = {
@@ -263,6 +265,9 @@ static GtkToggleActionEntry ephy_menu_toggle_entries [] =
{ "ViewFullscreen", STOCK_FULLSCREEN, N_("_Fullscreen"), "F11",
N_("Browse at full screen"),
G_CALLBACK (window_cmd_view_fullscreen), FALSE },
+ { "ViewPopupWindows", EPHY_STOCK_POPUPS, N_("Popup _Windows"), NULL,
+ N_("Show or hide unrequested popup windows from this site"),
+ G_CALLBACK (ephy_window_view_popup_windows_cb), FALSE },
{ "BrowseWithCaret", NULL, N_("Selection Caret"), "F7",
"",
G_CALLBACK (window_cmd_browse_with_caret), FALSE }
@@ -359,6 +364,7 @@ struct EphyWindowPrivate
guint disable_save_to_disk_notifier_id;
guint disable_command_line_notifier_id;
guint browse_with_caret_notifier_id;
+ guint allow_popups_notifier_id;
};
enum
@@ -1268,6 +1274,64 @@ sync_tab_security (EphyTab *tab, GParamSpec *pspec, EphyWindow *window)
}
static void
+sync_tab_popup_windows (EphyTab *tab,
+ GParamSpec *pspec,
+ EphyWindow *window)
+{
+ guint num_popups = 0;
+ char *tooltip = NULL;
+
+ g_object_get (G_OBJECT (tab),
+ "hidden-popup-count", &num_popups,
+ NULL);
+
+ if (num_popups > 0)
+ {
+ tooltip = g_strdup_printf (ngettext ("%d hidden popup window",
+ "%d hidden popup windows",
+ num_popups),
+ num_popups);
+ }
+
+ ephy_statusbar_set_popups_state
+ (EPHY_STATUSBAR (window->priv->statusbar),
+ tooltip == NULL,
+ tooltip);
+
+ g_free (tooltip);
+}
+
+static void
+sync_tab_popups_allowed (EphyTab *tab,
+ GParamSpec *pspec,
+ EphyWindow *window)
+{
+ GtkAction *action;
+ gboolean allow;
+
+ g_return_if_fail (EPHY_IS_TAB (tab));
+ g_return_if_fail (EPHY_IS_WINDOW (window));
+
+ action = gtk_action_group_get_action (window->priv->action_group,
+ "ViewPopupWindows");
+ g_return_if_fail (GTK_IS_ACTION (action));
+
+ g_object_get (G_OBJECT (tab), "popups-allowed", &allow, NULL);
+
+ g_signal_handlers_block_by_func
+ (G_OBJECT (action),
+ G_CALLBACK (ephy_window_view_popup_windows_cb),
+ window);
+
+ gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), allow);
+
+ g_signal_handlers_unblock_by_func
+ (G_OBJECT (action),
+ G_CALLBACK (ephy_window_view_popup_windows_cb),
+ window);
+}
+
+static void
sync_tab_load_status (EphyTab *tab, GParamSpec *pspec, EphyWindow *window)
{
GtkAction *action;
@@ -1555,6 +1619,12 @@ ephy_window_set_active_tab (EphyWindow *window, EphyTab *new_tab)
G_CALLBACK (sync_tab_security),
window);
g_signal_handlers_disconnect_by_func (G_OBJECT (old_tab),
+ G_CALLBACK (sync_tab_popup_windows),
+ window);
+ g_signal_handlers_disconnect_by_func (G_OBJECT (old_tab),
+ G_CALLBACK (sync_tab_popups_allowed),
+ window);
+ g_signal_handlers_disconnect_by_func (G_OBJECT (old_tab),
G_CALLBACK (sync_tab_title),
window);
g_signal_handlers_disconnect_by_func (G_OBJECT (old_tab),
@@ -1581,6 +1651,8 @@ ephy_window_set_active_tab (EphyWindow *window, EphyTab *new_tab)
sync_tab_message (new_tab, NULL, window);
sync_tab_navigation (new_tab, NULL, window);
sync_tab_security (new_tab, NULL, window);
+ sync_tab_popup_windows (new_tab, NULL, window);
+ sync_tab_popups_allowed (new_tab, NULL, window);
sync_tab_title (new_tab, NULL, window);
sync_tab_zoom (new_tab, NULL, window);
@@ -1613,6 +1685,14 @@ ephy_window_set_active_tab (EphyWindow *window, EphyTab *new_tab)
G_CALLBACK (sync_tab_security),
window, 0);
g_signal_connect_object (G_OBJECT (new_tab),
+ "notify::hidden-popup-count",
+ G_CALLBACK (sync_tab_popup_windows),
+ window, 0);
+ g_signal_connect_object (G_OBJECT (new_tab),
+ "notify::popups-allowed",
+ G_CALLBACK (sync_tab_popups_allowed),
+ window, 0);
+ g_signal_connect_object (G_OBJECT (new_tab),
"notify::title",
G_CALLBACK (sync_tab_title),
window, 0);
@@ -1829,6 +1909,9 @@ ephy_window_get_property (GObject *object,
case PROP_ACTIVE_TAB:
g_value_set_object (value, window->priv->active_tab);
break;
+ case PROP_CHROME:
+ g_value_set_flags (value, window->priv->chrome);
+ break;
}
}
@@ -1947,6 +2030,28 @@ browse_with_caret_notifier (GConfClient *client,
}
static void
+allow_popups_notifier (GConfClient *client,
+ guint cnxn_id,
+ GConfEntry *entry,
+ EphyWindow *window)
+{
+ GList *tabs;
+ EphyTab *tab;
+
+ g_return_if_fail (EPHY_IS_WINDOW (window));
+
+ tabs = ephy_window_get_tabs (window);
+
+ for (; tabs; tabs = g_list_next (tabs))
+ {
+ tab = EPHY_TAB (tabs->data);
+ g_return_if_fail (EPHY_IS_TAB (tab));
+
+ g_object_notify (G_OBJECT (tab), "popups-allowed");
+ }
+}
+
+static void
action_request_forward_cb (GObject *toolbar,
const char *name,
GObject *bookmarksbar)
@@ -1970,6 +2075,7 @@ ephy_window_init (EphyWindow *window)
window->priv->exit_fullscreen_popup = NULL;
window->priv->num_tabs = 0;
window->priv->has_size = FALSE;
+ window->priv->chrome = EPHY_EMBED_CHROME_ALL;
window->priv->should_save_chrome = FALSE;
window->priv->mode = EPHY_WINDOW_MODE_NORMAL;
@@ -2081,6 +2187,10 @@ ephy_window_init (EphyWindow *window)
(CONF_BROWSE_WITH_CARET,
(GConfClientNotifyFunc)browse_with_caret_notifier, window);
+ window->priv->allow_popups_notifier_id = eel_gconf_notification_add
+ (CONF_SECURITY_ALLOW_POPUPS,
+ (GConfClientNotifyFunc)allow_popups_notifier, window);
+
/* network status */
single = EPHY_EMBED_SINGLE (ephy_embed_shell_get_embed_single (embed_shell));
network_status_changed (single,
@@ -2114,6 +2224,7 @@ ephy_window_finalize (GObject *object)
eel_gconf_notification_remove (window->priv->disable_save_to_disk_notifier_id);
eel_gconf_notification_remove (window->priv->disable_command_line_notifier_id);
eel_gconf_notification_remove (window->priv->browse_with_caret_notifier_id);
+ eel_gconf_notification_remove (window->priv->allow_popups_notifier_id);
if (window->priv->find_dialog)
{
@@ -2380,7 +2491,7 @@ ephy_window_remove_tab (EphyWindow *window,
**/
void
ephy_window_load_url (EphyWindow *window,
- const char *url)
+ const char *url)
{
EphyEmbed *embed;
@@ -2697,3 +2808,27 @@ ephy_window_view_bookmarksbar_cb (GtkAction *action,
sync_chrome_with_view_toggle (action, window,
EPHY_EMBED_CHROME_BOOKMARKSBAR);
}
+
+static void
+ephy_window_view_popup_windows_cb (GtkAction *action,
+ EphyWindow *window)
+{
+ EphyTab *tab;
+ gboolean allow;
+
+ g_return_if_fail (EPHY_IS_WINDOW (window));
+
+ tab = ephy_window_get_active_tab (window);
+ g_return_if_fail (EPHY_IS_TAB (tab));
+
+ if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)))
+ {
+ allow = TRUE;
+ }
+ else
+ {
+ allow = FALSE;
+ }
+
+ g_object_set (G_OBJECT (tab), "popups-allowed", allow, NULL);
+}