aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ephy-tab.c48
-rw-r--r--src/ephy-tab.h2
-rw-r--r--src/ephy-window.c54
-rwxr-xr-xsrc/toolbar.c8
-rw-r--r--src/toolbar.h1
5 files changed, 106 insertions, 7 deletions
diff --git a/src/ephy-tab.c b/src/ephy-tab.c
index f6e20e6d4..1cce14579 100644
--- a/src/ephy-tab.c
+++ b/src/ephy-tab.c
@@ -85,6 +85,7 @@ struct _EphyTabPrivate
GSList *hidden_popups;
GSList *shown_popups;
TabNavigationFlags nav_flags;
+ EmbedDocumentType document_type;
};
static void ephy_tab_class_init (EphyTabClass *klass);
@@ -95,6 +96,7 @@ enum
{
PROP_0,
PROP_ADDRESS,
+ PROP_DOCUMENT_TYPE,
PROP_ICON,
PROP_LOAD_PROGRESS,
PROP_LOAD_STATUS,
@@ -190,6 +192,7 @@ ephy_tab_set_property (GObject *object,
ephy_tab_set_popups_allowed
(tab, g_value_get_boolean (value));
break;
+ case PROP_DOCUMENT_TYPE:
case PROP_ICON:
case PROP_LOAD_PROGRESS:
case PROP_LOAD_STATUS:
@@ -218,6 +221,9 @@ ephy_tab_get_property (GObject *object,
case PROP_ADDRESS:
g_value_set_string (value, tab->priv->address);
break;
+ case PROP_DOCUMENT_TYPE:
+ g_value_set_enum (value, tab->priv->document_type);
+ break;
case PROP_ICON:
g_value_set_string (value, tab->priv->icon_address);
break;
@@ -352,6 +358,15 @@ ephy_tab_class_init (EphyTabClass *class)
G_PARAM_READWRITE));
g_object_class_install_property (object_class,
+ PROP_DOCUMENT_TYPE,
+ g_param_spec_enum ("document-type",
+ "Document Type",
+ "The tab's documen type",
+ EPHY_TYPE_EMBED_DOCUMENT_TYPE,
+ EMBED_DOCUMENT_HTML,
+ G_PARAM_READABLE));
+
+ g_object_class_install_property (object_class,
PROP_ICON,
g_param_spec_string ("icon",
"Icon address",
@@ -783,6 +798,22 @@ ephy_tab_set_load_status (EphyTab *tab, gboolean status)
}
/**
+ * ephy_tab_get_document_type:
+ * @tab: an #EphyTab
+ *
+ * Returns the type of the document loaded in @tab.
+ *
+ * Return value: the #EmbedDocumentType
+ **/
+EmbedDocumentType
+ephy_tab_get_document_type (EphyTab *tab)
+{
+ g_return_val_if_fail (EPHY_IS_TAB (tab), EMBED_DOCUMENT_OTHER);
+
+ return tab->priv->document_type;
+}
+
+/**
* ephy_tab_get_load_status:
* @tab: an #EphyTab
*
@@ -1050,6 +1081,19 @@ ephy_tab_content_change_cb (EphyEmbed *embed, const char *address, EphyTab *tab)
}
static void
+ephy_tab_document_type_cb (EphyEmbed *embed,
+ EmbedDocumentType type,
+ EphyTab *tab)
+{
+ if (tab->priv->document_type != type)
+ {
+ tab->priv->document_type = type;
+g_print ("new doc type %d\n", type);
+ g_object_notify (G_OBJECT (tab), "document-type");
+ }
+}
+
+static void
ephy_tab_zoom_changed_cb (EphyEmbed *embed, float zoom, EphyTab *tab)
{
char *address;
@@ -1557,6 +1601,7 @@ ephy_tab_init (EphyTab *tab)
tab->priv->load_percent = 0;
tab->priv->load_status = FALSE;
tab->priv->security_level = STATE_IS_UNKNOWN;
+ tab->priv->document_type = EMBED_DOCUMENT_HTML;
tab->priv->zoom = 1.0;
tab->priv->address_expire = TAB_ADDRESS_EXPIRE_NOW;
@@ -1581,6 +1626,9 @@ ephy_tab_init (EphyTab *tab)
g_signal_connect_object (embed, "link_message",
G_CALLBACK (ephy_tab_link_message_cb),
tab, 0);
+ g_signal_connect_object (embed, "ge_document_type",
+ G_CALLBACK (ephy_tab_document_type_cb),
+ tab, 0);
g_signal_connect_object (embed, "ge_location",
G_CALLBACK (ephy_tab_address_cb),
tab, 0);
diff --git a/src/ephy-tab.h b/src/ephy-tab.h
index b94ec81eb..133fe4ccc 100644
--- a/src/ephy-tab.h
+++ b/src/ephy-tab.h
@@ -76,6 +76,8 @@ EphyEmbed *ephy_tab_get_embed (EphyTab *tab);
EphyTab *ephy_tab_for_embed (EphyEmbed *embed);
+EmbedDocumentType ephy_tab_get_document_type (EphyTab *tab);
+
const char *ephy_tab_get_icon_address (EphyTab *tab);
gboolean ephy_tab_get_load_status (EphyTab *tab);
diff --git a/src/ephy-window.c b/src/ephy-window.c
index 3c08bf238..75ab35961 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -82,6 +82,9 @@ static void ephy_window_view_bookmarksbar_cb (GtkAction *action,
EphyWindow *window);
static void ephy_window_view_popup_windows_cb (GtkAction *action,
EphyWindow *window);
+static void sync_tab_zoom (EphyTab *tab,
+ GParamSpec *pspec,
+ EphyWindow *window);
static GtkActionEntry ephy_menu_entries [] = {
@@ -1208,6 +1211,36 @@ sync_tab_address (EphyTab *tab, GParamSpec *pspec, EphyWindow *window)
}
static void
+sync_tab_document_type (EphyTab *tab,
+ GParamSpec *pspec,
+ EphyWindow *window)
+{
+ GtkActionGroup *action_group;
+ GtkAction *action;
+ EmbedDocumentType type;
+ gboolean can_find, enable;
+
+ /* update zoom actions */
+ sync_tab_zoom (tab, NULL, window);
+
+ type = ephy_tab_get_document_type (tab);
+ can_find = (type != EMBED_DOCUMENT_IMAGE);
+ enable = (type == EMBED_DOCUMENT_HTML);
+
+ action_group = window->priv->action_group;
+ action = gtk_action_group_get_action (action_group, "ViewEncoding");
+ g_object_set (action, "sensitive", enable, NULL);
+ action = gtk_action_group_get_action (action_group, "ViewPageSource");
+ g_object_set (action, "sensitive", enable, NULL);
+ action = gtk_action_group_get_action (action_group, "EditFind");
+ g_object_set (action, "sensitive", can_find, NULL);
+ action = gtk_action_group_get_action (action_group, "EditFindNext");
+ g_object_set (action, "sensitive", can_find, NULL);
+ action = gtk_action_group_get_action (action_group, "EditFindPrev");
+ g_object_set (action, "sensitive", can_find, NULL);
+}
+
+static void
sync_tab_icon (EphyTab *tab, GParamSpec *pspec, EphyWindow *window)
{
const char *address;
@@ -1507,12 +1540,15 @@ sync_tab_zoom (EphyTab *tab, GParamSpec *pspec, EphyWindow *window)
{
GtkActionGroup *action_group;
GtkAction *action;
- gboolean can_zoom_in = TRUE, can_zoom_out = TRUE, can_zoom_normal = FALSE;
+ EmbedDocumentType type;
+ gboolean can_zoom_in = TRUE, can_zoom_out = TRUE, can_zoom_normal = FALSE, can_zoom;
float zoom;
if (window->priv->closing) return;
zoom = ephy_tab_get_zoom (tab);
+ type = ephy_tab_get_document_type (tab);
+ can_zoom = (type != EMBED_DOCUMENT_IMAGE);
if (zoom >= ZOOM_MAXIMAL)
{
@@ -1527,15 +1563,15 @@ sync_tab_zoom (EphyTab *tab, GParamSpec *pspec, EphyWindow *window)
can_zoom_normal = TRUE;
}
- toolbar_update_zoom (window->priv->toolbar, zoom);
+ toolbar_update_zoom (window->priv->toolbar, can_zoom, zoom);
action_group = window->priv->action_group;
action = gtk_action_group_get_action (action_group, "ViewZoomIn");
- g_object_set (action, "sensitive", can_zoom_in, NULL);
+ g_object_set (action, "sensitive", can_zoom_in && can_zoom, NULL);
action = gtk_action_group_get_action (action_group, "ViewZoomOut");
- g_object_set (action, "sensitive", can_zoom_out, NULL);
+ g_object_set (action, "sensitive", can_zoom_out && can_zoom, NULL);
action = gtk_action_group_get_action (action_group, "ViewZoomNormal");
- g_object_set (action, "sensitive", can_zoom_normal, NULL);
+ g_object_set (action, "sensitive", can_zoom_normal && can_zoom, NULL);
}
static void
@@ -1833,6 +1869,9 @@ ephy_window_set_active_tab (EphyWindow *window, EphyTab *new_tab)
G_CALLBACK (sync_tab_address),
window);
g_signal_handlers_disconnect_by_func (G_OBJECT (old_tab),
+ G_CALLBACK (sync_tab_document_type),
+ window);
+ g_signal_handlers_disconnect_by_func (G_OBJECT (old_tab),
G_CALLBACK (sync_tab_icon),
window);
g_signal_handlers_disconnect_by_func (G_OBJECT (old_tab),
@@ -1877,6 +1916,7 @@ ephy_window_set_active_tab (EphyWindow *window, EphyTab *new_tab)
if (new_tab)
{
sync_tab_address (new_tab, NULL, window);
+ sync_tab_document_type (new_tab, NULL, window);
sync_tab_icon (new_tab, NULL, window);
sync_tab_load_progress (new_tab, NULL, window);
sync_tab_load_status (new_tab, NULL, window);
@@ -1893,6 +1933,10 @@ ephy_window_set_active_tab (EphyWindow *window, EphyTab *new_tab)
G_CALLBACK (sync_tab_address),
window, 0);
g_signal_connect_object (G_OBJECT (new_tab),
+ "notify::document-type",
+ G_CALLBACK (sync_tab_document_type),
+ window, 0);
+ g_signal_connect_object (G_OBJECT (new_tab),
"notify::icon",
G_CALLBACK (sync_tab_icon),
window, 0);
diff --git a/src/toolbar.c b/src/toolbar.c
index d93eee48f..2e2424a12 100755
--- a/src/toolbar.c
+++ b/src/toolbar.c
@@ -639,14 +639,18 @@ toolbar_update_navigation_actions (Toolbar *t, gboolean back, gboolean forward,
}
void
-toolbar_update_zoom (Toolbar *t, float zoom)
+toolbar_update_zoom (Toolbar *t,
+ gboolean can_zoom,
+ float zoom)
{
GtkActionGroup *action_group;
GtkAction *action;
action_group = t->priv->action_group;
action = gtk_action_group_get_action (action_group, "Zoom");
- g_object_set (action, "zoom", zoom, NULL);
+ g_object_set (action, "zoom", can_zoom ? zoom : 1.0,
+ "sensitive", can_zoom,
+ NULL);
}
Toolbar *
diff --git a/src/toolbar.h b/src/toolbar.h
index dc9cb5271..086943d40 100644
--- a/src/toolbar.h
+++ b/src/toolbar.h
@@ -81,6 +81,7 @@ void toolbar_update_navigation_actions (Toolbar *t,
gboolean up);
void toolbar_update_zoom (Toolbar *t,
+ gboolean can_zoom,
float zoom);
G_END_DECLS