aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDiego Escalante Urrelo <diegoe@igalia.com>2012-01-23 07:41:47 +0800
committerDiego Escalante Urrelo <diegoe@igalia.com>2012-01-24 01:14:10 +0800
commit7511ee0b55d81858cb62c798854df29b135b517f (patch)
treeaa553ea8babde32a1f096f0d551c79fd12e2c01a
parentd626c6f1b880beabd1631f10891562067d287e28 (diff)
downloadgsoc2013-epiphany-7511ee0b55d81858cb62c798854df29b135b517f.tar
gsoc2013-epiphany-7511ee0b55d81858cb62c798854df29b135b517f.tar.gz
gsoc2013-epiphany-7511ee0b55d81858cb62c798854df29b135b517f.tar.bz2
gsoc2013-epiphany-7511ee0b55d81858cb62c798854df29b135b517f.tar.lz
gsoc2013-epiphany-7511ee0b55d81858cb62c798854df29b135b517f.tar.xz
gsoc2013-epiphany-7511ee0b55d81858cb62c798854df29b135b517f.tar.zst
gsoc2013-epiphany-7511ee0b55d81858cb62c798854df29b135b517f.zip
ephy-window: sync page actions with is-blank property
Add ::is-blank property to EphyWebView and update EphyWindow to sync some of the page menu actions with it. There's no point in enabling save/reload/bookmark/etc on about:blank. https://bugzilla.gnome.org/show_bug.cgi?id=668105
-rw-r--r--embed/ephy-web-view.c45
-rw-r--r--src/ephy-window.c98
2 files changed, 139 insertions, 4 deletions
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c
index 4a031648e..7c2e89ec4 100644
--- a/embed/ephy-web-view.c
+++ b/embed/ephy-web-view.c
@@ -125,6 +125,7 @@ enum {
PROP_EMBED_TITLE,
PROP_TYPED_ADDRESS,
PROP_VISIBLE,
+ PROP_IS_BLANK,
};
#define EPHY_WEB_VIEW_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_WEB_VIEW, EphyWebViewPrivate))
@@ -448,6 +449,9 @@ ephy_web_view_get_property (GObject *object,
case PROP_VISIBLE:
g_value_set_boolean (value, priv->visibility);
break;
+ case PROP_IS_BLANK:
+ g_value_set_boolean (value, priv->is_blank);
+ break;
default:
break;
}
@@ -477,6 +481,7 @@ ephy_web_view_set_property (GObject *object,
case PROP_STATUS_MESSAGE:
case PROP_EMBED_TITLE:
case PROP_VISIBLE:
+ case PROP_IS_BLANK:
/* read only */
break;
default:
@@ -1301,6 +1306,19 @@ ephy_web_view_class_init (EphyWebViewClass *klass)
G_PARAM_READABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
/**
+ * EphyWebView:is-blank:
+ *
+ * Whether the view is showing the blank address.
+ **/
+ g_object_class_install_property (gobject_class,
+ PROP_IS_BLANK,
+ g_param_spec_boolean ("is-blank",
+ "Is blank",
+ "If the EphyWebView is blank",
+ FALSE,
+ G_PARAM_READABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
+
+/**
* EphyWebView::new-window:
* @view: the #EphyWebView that received the signal
* @new_view: the newly opened #EphyWebView
@@ -2489,6 +2507,25 @@ ephy_web_view_clear_history (EphyWebView *view)
}
/**
+ * ephy_web_view_set_is_blank:
+ * @view: an #EphyWebView
+ * @is_blank: if @view is the blank page
+ *
+ * Sets whether the @view's address is "blank".
+ **/
+static void
+_ephy_web_view_set_is_blank (EphyWebView *view,
+ gboolean is_blank)
+{
+ EphyWebViewPrivate *priv = view->priv;
+
+ if (priv->is_blank != is_blank) {
+ priv->is_blank = is_blank;
+ g_object_notify (G_OBJECT (view), "is-blank");
+ }
+}
+
+/**
* ephy_web_view_set_address:
* @view: an #EphyWebView
* @address: address to set @view to
@@ -2502,12 +2539,14 @@ ephy_web_view_set_address (EphyWebView *view,
{
EphyWebViewPrivate *priv = view->priv;
GObject *object = G_OBJECT (view);
+ gboolean is_blank;
g_free (priv->address);
priv->address = g_strdup (address);
- priv->is_blank = address == NULL ||
- strcmp (address, "about:blank") == 0;
+ is_blank = address == NULL ||
+ strcmp (address, "about:blank") == 0;
+ _ephy_web_view_set_is_blank (view, is_blank);
if (ephy_web_view_is_loading (view) &&
priv->expire_address_now == TRUE &&
@@ -2554,7 +2593,7 @@ ephy_web_view_set_title (EphyWebView *view,
if (title == NULL || title[0] == '\0') {
g_free (title);
title = g_strdup (EMPTY_PAGE);
- priv->is_blank = TRUE;
+ _ephy_web_view_set_is_blank (view, TRUE);
}
} else if (priv->is_blank) {
g_free (title);
diff --git a/src/ephy-window.c b/src/ephy-window.c
index 1b5737a66..9bba5c36b 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -420,7 +420,8 @@ enum
SENS_FLAG_CONTEXT = 1 << 1,
SENS_FLAG_DOCUMENT = 1 << 2,
SENS_FLAG_LOADING = 1 << 3,
- SENS_FLAG_NAVIGATION = 1 << 4
+ SENS_FLAG_NAVIGATION = 1 << 4,
+ SENS_FLAG_IS_BLANK = 1 << 5
};
static gint
@@ -1689,6 +1690,95 @@ sync_tab_navigation (EphyWebView *view,
}
static void
+sync_tab_is_blank (EphyWebView *view,
+ GParamSpec *pspec,
+ EphyWindow *window)
+{
+ EphyWindowPrivate *priv = window->priv;
+ GtkActionGroup *action_group;
+ GtkAction *action;
+ gboolean is_blank = TRUE;
+
+ if (window->priv->closing) return;
+
+ is_blank = ephy_web_view_get_is_blank (view);
+ action_group = priv->action_group;
+
+ /* Page menu */
+ action = gtk_action_group_get_action (action_group,
+ "FileSaveAs");
+ ephy_action_change_sensitivity_flags (action,
+ SENS_FLAG_IS_BLANK, is_blank);
+
+ action = gtk_action_group_get_action (action_group,
+ "FileSaveAsApplication");
+ ephy_action_change_sensitivity_flags (action,
+ SENS_FLAG_IS_BLANK, is_blank);
+
+ action = gtk_action_group_get_action (action_group,
+ "FilePrint");
+ ephy_action_change_sensitivity_flags (action,
+ SENS_FLAG_IS_BLANK, is_blank);
+
+ action = gtk_action_group_get_action (action_group,
+ "FileSendTo");
+ ephy_action_change_sensitivity_flags (action,
+ SENS_FLAG_IS_BLANK, is_blank);
+
+ action = gtk_action_group_get_action (action_group,
+ "FileBookmarkPage");
+ ephy_action_change_sensitivity_flags (action,
+ SENS_FLAG_IS_BLANK, is_blank);
+
+ action = gtk_action_group_get_action (action_group,
+ "EditFind");
+ ephy_action_change_sensitivity_flags (action,
+ SENS_FLAG_IS_BLANK, is_blank);
+
+ action = gtk_action_group_get_action (action_group,
+ "EditFind");
+ ephy_action_change_sensitivity_flags (action,
+ SENS_FLAG_IS_BLANK, is_blank);
+
+ action = gtk_action_group_get_action (action_group,
+ "ViewEncoding");
+ ephy_action_change_sensitivity_flags (action,
+ SENS_FLAG_IS_BLANK, is_blank);
+
+ action = gtk_action_group_get_action (action_group,
+ "ViewZoomIn");
+ ephy_action_change_sensitivity_flags (action,
+ SENS_FLAG_IS_BLANK, is_blank);
+
+ action = gtk_action_group_get_action (action_group,
+ "ViewZoomOut");
+ ephy_action_change_sensitivity_flags (action,
+ SENS_FLAG_IS_BLANK, is_blank);
+
+ action = gtk_action_group_get_action (action_group,
+ "ViewPageSource");
+ ephy_action_change_sensitivity_flags (action,
+ SENS_FLAG_IS_BLANK, is_blank);
+
+ /* Page context popup */
+ action = gtk_action_group_get_action (priv->popups_action_group,
+ "ContextBookmarkPage");
+ ephy_action_change_sensitivity_flags (action,
+ SENS_FLAG_IS_BLANK, is_blank);
+
+ action = gtk_action_group_get_action (priv->popups_action_group,
+ "InspectElement");
+ ephy_action_change_sensitivity_flags (action,
+ SENS_FLAG_IS_BLANK, is_blank);
+
+ /* Toolbar */
+ action = gtk_action_group_get_action (priv->toolbar_action_group,
+ "ViewCombinedStopReload");
+ ephy_action_change_sensitivity_flags (action,
+ SENS_FLAG_IS_BLANK, is_blank);
+}
+
+static void
sync_tab_popup_windows (EphyWebView *view,
GParamSpec *pspec,
EphyWindow *window)
@@ -2469,6 +2559,9 @@ ephy_window_set_active_tab (EphyWindow *window, EphyEmbed *new_embed)
G_CALLBACK (sync_tab_load_status),
window);
g_signal_handlers_disconnect_by_func (view,
+ G_CALLBACK (sync_tab_is_blank),
+ window);
+ g_signal_handlers_disconnect_by_func (view,
G_CALLBACK (sync_tab_navigation),
window);
g_signal_handlers_disconnect_by_func (view,
@@ -2563,6 +2656,9 @@ ephy_window_set_active_tab (EphyWindow *window, EphyEmbed *new_embed)
g_signal_connect_object (view, "notify::navigation",
G_CALLBACK (sync_tab_navigation),
window, 0);
+ g_signal_connect_object (view, "notify::is-blank",
+ G_CALLBACK (sync_tab_is_blank),
+ window, 0);
/* We run our button-press-event after the default
* handler to make sure pages have a chance to perform
* their own handling - for instance, have their own