aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--embed/ephy-embed.c9
-rw-r--r--embed/mozilla/mozilla-embed.cpp112
-rw-r--r--src/ephy-tab.c119
-rw-r--r--src/ephy-window.c26
-rw-r--r--src/epiphany.defs8
5 files changed, 134 insertions, 140 deletions
diff --git a/embed/ephy-embed.c b/embed/ephy-embed.c
index c9a839e2b..97e46d6a3 100644
--- a/embed/ephy-embed.c
+++ b/embed/ephy-embed.c
@@ -21,6 +21,7 @@
#include "config.h"
#include "ephy-embed.h"
+#include "ephy-zoom.h"
#include "ephy-embed-type-builtins.h"
#include "ephy-marshal.h"
@@ -437,6 +438,14 @@ ephy_embed_base_init (gpointer g_class)
EPHY_TYPE_EMBED_DOCUMENT_TYPE,
EPHY_EMBED_DOCUMENT_HTML,
G_PARAM_READABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
+ g_object_interface_install_property (g_class,
+ g_param_spec_float ("zoom",
+ "Zoom",
+ "The embed's zoom",
+ ZOOM_MINIMAL,
+ ZOOM_MAXIMAL,
+ 1.0,
+ G_PARAM_READABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
initialized = TRUE;
}
diff --git a/embed/mozilla/mozilla-embed.cpp b/embed/mozilla/mozilla-embed.cpp
index 2d6271db5..538641804 100644
--- a/embed/mozilla/mozilla-embed.cpp
+++ b/embed/mozilla/mozilla-embed.cpp
@@ -41,6 +41,7 @@
#include "ephy-debug.h"
#include "ephy-embed-shell.h"
#include "ephy-embed-single.h"
+#include "ephy-history.h"
#include "ephy-string.h"
#include "mozilla-embed-event.h"
@@ -79,6 +80,9 @@ static void mozilla_embed_security_change_cb (GtkMozEmbed *embed,
static void mozilla_embed_document_type_cb (EphyEmbed *embed,
EphyEmbedDocumentType type,
MozillaEmbed *membed);
+static void mozilla_embed_zoom_change_cb (EphyEmbed *embed,
+ float zoom,
+ MozillaEmbed *membed);
static EphyEmbedSecurityLevel mozilla_embed_security_level (PRUint32 state);
@@ -100,6 +104,8 @@ struct MozillaEmbedPrivate
EphyEmbedSecurityLevel security_level;
/* guint security_level : 3; ? */
EphyEmbedDocumentType document_type;
+ float zoom;
+ guint is_setting_zoom : 1;
};
#define WINDOWWATCHER_CONTRACTID "@mozilla.org/embedcomp/window-watcher;1"
@@ -108,7 +114,8 @@ enum
{
PROP_0,
PROP_DOCUMENT_TYPE,
- PROP_SECURITY
+ PROP_SECURITY,
+ PROP_ZOOM
};
static void
@@ -218,6 +225,9 @@ mozilla_embed_get_property (GObject *object,
case PROP_SECURITY:
g_value_set_enum (value, priv->security_level);
break;
+ case PROP_ZOOM:
+ g_value_set_float (value, priv->zoom);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -235,6 +245,7 @@ mozilla_embed_set_property (GObject *object,
{
case PROP_DOCUMENT_TYPE:
case PROP_SECURITY:
+ case PROP_ZOOM:
/* read only */
break;
default:
@@ -264,6 +275,7 @@ mozilla_embed_class_init (MozillaEmbedClass *klass)
g_object_class_override_property (object_class, PROP_DOCUMENT_TYPE, "document-type");
g_object_class_override_property (object_class, PROP_SECURITY, "security-level");
+ g_object_class_override_property (object_class, PROP_ZOOM, "zoom");
g_type_class_add_private (object_class, sizeof(MozillaEmbedPrivate));
}
@@ -298,9 +310,14 @@ mozilla_embed_init (MozillaEmbed *embed)
g_signal_connect_object (embed, "ge_document_type",
G_CALLBACK (mozilla_embed_document_type_cb),
embed, (GConnectFlags) 0);
+ g_signal_connect_object (embed, "ge_zoom_change",
+ G_CALLBACK (mozilla_embed_zoom_change_cb),
+ embed, (GConnectFlags) 0);
embed->priv->document_type = EPHY_EMBED_DOCUMENT_HTML;
embed->priv->security_level = EPHY_EMBED_STATE_IS_UNKNOWN;
+ embed->priv->zoom = 1.0;
+ embed->priv->is_setting_zoom = FALSE;
}
gpointer
@@ -890,6 +907,58 @@ mozilla_embed_location_changed_cb (GtkMozEmbed *embed,
g_free (location);
}
+static gboolean
+address_has_web_scheme (const char *address)
+{
+ gboolean has_web_scheme;
+
+ if (address == NULL) return FALSE;
+
+ has_web_scheme = (g_str_has_prefix (address, "http:") ||
+ g_str_has_prefix (address, "https:") ||
+ g_str_has_prefix (address, "ftp:") ||
+ g_str_has_prefix (address, "file:") ||
+ g_str_has_prefix (address, "data:") ||
+ g_str_has_prefix (address, "about:") ||
+ g_str_has_prefix (address, "gopher:"));
+
+ return has_web_scheme;
+}
+
+static void
+mozilla_embed_restore_zoom_level (MozillaEmbed *membed, const char *address)
+{
+ MozillaEmbedPrivate *priv = membed->priv;
+
+ /* restore zoom level */
+ if (address_has_web_scheme (address))
+ {
+ EphyHistory *history;
+ EphyNode *host;
+ GValue value = { 0, };
+ float zoom = 1.0, current_zoom;
+
+ history = EPHY_HISTORY
+ (ephy_embed_shell_get_global_history (embed_shell));
+ host = ephy_history_get_host (history, address);
+
+ if (host != NULL && ephy_node_get_property
+ (host, EPHY_NODE_HOST_PROP_ZOOM, &value))
+ {
+ zoom = g_value_get_float (&value);
+ g_value_unset (&value);
+ }
+
+ current_zoom = ephy_embed_get_zoom (EPHY_EMBED (membed));
+ if (zoom != current_zoom)
+ {
+ priv->is_setting_zoom = TRUE;
+ ephy_embed_set_zoom (EPHY_EMBED (membed), zoom);
+ priv->is_setting_zoom = FALSE;
+ }
+ }
+}
+
static void
update_load_state (MozillaEmbed *membed, gint state)
{
@@ -910,6 +979,7 @@ update_load_state (MozillaEmbed *membed, gint state)
char *address;
address = gtk_moz_embed_get_location (GTK_MOZ_EMBED (membed));
g_signal_emit_by_name (membed, "ge-content-change", address);
+ mozilla_embed_restore_zoom_level (membed, address);
g_free (address);
}
@@ -938,6 +1008,7 @@ update_load_state (MozillaEmbed *membed, gint state)
char *address;
address = gtk_moz_embed_get_location (GTK_MOZ_EMBED (membed));
g_signal_emit_by_name (membed, "ge_content_change", address);
+ mozilla_embed_restore_zoom_level (membed, address);
g_free (address);
}
}
@@ -1171,6 +1242,45 @@ mozilla_embed_document_type_cb (EphyEmbed *embed,
}
}
+static void
+mozilla_embed_zoom_change_cb (EphyEmbed *embed,
+ float zoom,
+ MozillaEmbed *membed)
+{
+ char *address;
+
+ if (membed->priv->zoom != zoom)
+ {
+ if (membed->priv->is_setting_zoom)
+ {
+ return;
+ }
+
+ address = ephy_embed_get_location (embed, TRUE);
+ if (address_has_web_scheme (address))
+ {
+ EphyHistory *history;
+ EphyNode *host;
+ history = EPHY_HISTORY
+ (ephy_embed_shell_get_global_history (embed_shell));
+ host = ephy_history_get_host (history, address);
+
+ if (host != NULL)
+ {
+ ephy_node_set_property_float (host,
+ EPHY_NODE_HOST_PROP_ZOOM,
+ zoom);
+ }
+ }
+
+ g_free (address);
+
+ membed->priv->zoom = zoom;
+
+ g_object_notify (G_OBJECT (membed), "zoom");
+ }
+}
+
static EphyEmbedSecurityLevel
mozilla_embed_security_level (PRUint32 state)
{
diff --git a/src/ephy-tab.c b/src/ephy-tab.c
index d22a6abd5..b7b4852ad 100644
--- a/src/ephy-tab.c
+++ b/src/ephy-tab.c
@@ -93,7 +93,6 @@ struct _EphyTabPrivate
int total_requests;
int width;
int height;
- float zoom;
GSList *hidden_popups;
GSList *shown_popups;
EphyTabNavigationFlags nav_flags;
@@ -103,7 +102,6 @@ struct _EphyTabPrivate
/* Flags */
guint is_blank : 1;
guint is_loading : 1;
- guint is_setting_zoom : 1;
EphyTabAddressExpire address_expire;
/* guint address_expire : 2; ? */
@@ -131,8 +129,7 @@ enum
PROP_HIDDEN_POPUP_COUNT,
PROP_POPUPS_ALLOWED,
PROP_TITLE,
- PROP_TYPED_ADDRESS,
- PROP_ZOOM
+ PROP_TYPED_ADDRESS
};
typedef struct
@@ -164,8 +161,6 @@ static void ephy_tab_update_navigation_flags(EphyTab *tab,
static void ephy_tab_set_title (EphyTab *tab,
EphyEmbed *embed,
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_allowed (EphyTab *tab);
static void ephy_tab_set_popups_allowed (EphyTab *tab,
@@ -242,7 +237,6 @@ ephy_tab_set_property (GObject *object,
case PROP_NAVIGATION:
case PROP_HIDDEN_POPUP_COUNT:
case PROP_TITLE:
- case PROP_ZOOM:
/* read only */
break;
}
@@ -293,9 +287,6 @@ ephy_tab_get_property (GObject *object,
case PROP_TYPED_ADDRESS:
g_value_set_string (value, ephy_tab_get_typed_address (tab));
break;
- case PROP_ZOOM:
- g_value_set_float (value, priv->zoom);
- break;
}
}
@@ -481,16 +472,6 @@ ephy_tab_class_init (EphyTabClass *class)
"",
G_PARAM_READWRITE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
- g_object_class_install_property (object_class,
- PROP_ZOOM,
- g_param_spec_float ("zoom",
- "Zoom",
- "The tab's zoom",
- ZOOM_MINIMAL,
- ZOOM_MAXIMAL,
- 1.0,
- G_PARAM_READABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
-
g_type_class_add_private (object_class, sizeof (EphyTabPrivate));
}
@@ -1530,78 +1511,11 @@ ephy_tab_address_cb (EphyEmbed *embed,
static void
ephy_tab_content_change_cb (EphyEmbed *embed, const char *address, EphyTab *tab)
{
- EphyTabPrivate *priv = tab->priv;
-
- /* restore zoom level */
- if (address_has_web_scheme (address))
- {
- EphyHistory *history;
- EphyNode *host;
- GValue value = { 0, };
- float zoom = 1.0, current_zoom;
-
- history = EPHY_HISTORY
- (ephy_embed_shell_get_global_history (embed_shell));
- host = ephy_history_get_host (history, address);
-
- if (host != NULL && ephy_node_get_property
- (host, EPHY_NODE_HOST_PROP_ZOOM, &value))
- {
- zoom = g_value_get_float (&value);
- g_value_unset (&value);
- }
-
- current_zoom = ephy_embed_get_zoom (embed);
- if (zoom != current_zoom)
- {
- priv->is_setting_zoom = TRUE;
- ephy_embed_set_zoom (embed, zoom);
- priv->is_setting_zoom = FALSE;
- }
- }
-
popups_manager_reset (tab);
g_object_notify (G_OBJECT (tab), "popups-allowed");
}
static void
-ephy_tab_zoom_changed_cb (EphyEmbed *embed, float zoom, EphyTab *tab)
-{
- char *address;
-
- LOG ("ephy_tab_zoom_changed_cb tab %p zoom %f", tab, zoom);
-
- ephy_tab_set_zoom (tab, zoom);
-
- if (tab->priv->is_setting_zoom)
- {
- return;
- }
-
- address = ephy_embed_get_location (embed, TRUE);
- if (address_has_web_scheme (address))
- {
- EphyHistory *history;
- EphyNode *host;
- history = EPHY_HISTORY
- (ephy_embed_shell_get_global_history (embed_shell));
- host = ephy_history_get_host (history, address);
-
- if (host != NULL)
- {
- float zoom;
-
- zoom = ephy_embed_get_zoom (embed);
- ephy_node_set_property_float (host,
- EPHY_NODE_HOST_PROP_ZOOM,
- zoom);
- }
- }
-
- g_free (address);
-}
-
-static void
ephy_tab_title_cb (EphyEmbed *embed,
EphyTab *tab)
{
@@ -2041,7 +1955,6 @@ ephy_tab_init (EphyTab *tab)
tab->priv->height = -1;
tab->priv->load_percent = 0;
tab->priv->is_loading = FALSE;
- tab->priv->zoom = 1.0;
priv->title = NULL;
priv->is_blank = TRUE;
priv->icon_address = NULL;
@@ -2071,9 +1984,6 @@ ephy_tab_init (EphyTab *tab)
g_signal_connect_object (embed, "title",
G_CALLBACK (ephy_tab_title_cb),
tab, 0);
- g_signal_connect_object (embed, "ge_zoom_change",
- G_CALLBACK (ephy_tab_zoom_changed_cb),
- tab, 0);
g_signal_connect_object (embed, "ge_net_state",
G_CALLBACK (ephy_tab_net_state_cb),
tab, 0);
@@ -2395,33 +2305,6 @@ ephy_tab_set_typed_address (EphyTab *tab,
g_object_notify (G_OBJECT (tab), "typed-address");
}
-static void
-ephy_tab_set_zoom (EphyTab *tab, float zoom)
-{
- g_return_if_fail (EPHY_IS_TAB (tab));
-
- tab->priv->zoom = zoom;
-
- g_object_notify (G_OBJECT (tab), "zoom");
-}
-
-/**
- * ephy_tab_get_zoom:
- * @tab: an #EphyTab
- *
- * Returns the zoom level of the web page loaded in @tab. A return value of
- * 1.0 corresponds to 100% zoom (normal size).
- *
- * Return value: @tab's loaded page's zoom level
- **/
-float
-ephy_tab_get_zoom (EphyTab *tab)
-{
- g_return_val_if_fail (EPHY_IS_TAB (tab), 1.0);
-
- return tab->priv->zoom;
-}
-
/* private */
guint
_ephy_tab_get_id (EphyTab *tab)
diff --git a/src/ephy-window.c b/src/ephy-window.c
index 47c02f5be..efeb48605 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -103,7 +103,7 @@ static void sync_tab_load_status (EphyTab *tab,
static void sync_tab_security (EphyEmbed *embed,
GParamSpec *pspec,
EphyWindow *window);
-static void sync_tab_zoom (EphyTab *tab,
+static void sync_tab_zoom (EphyEmbed *embed,
GParamSpec *pspec,
EphyWindow *window);
@@ -1401,8 +1401,7 @@ sync_tab_document_type (EphyEmbed *embed,
if (priv->closing) return;
/* update zoom actions */
- /* FIXME: need to move zoom to embed to uncomment this
- sync_tab_zoom (tab, NULL, window);*/
+ sync_tab_zoom (embed, NULL, window);
type = ephy_embed_get_document_type (embed);
can_find = (type != EPHY_EMBED_DOCUMENT_IMAGE);
@@ -1719,7 +1718,7 @@ sync_tab_title (EphyTab *tab,
}
static void
-sync_tab_zoom (EphyTab *tab, GParamSpec *pspec, EphyWindow *window)
+sync_tab_zoom (EphyEmbed *embed, GParamSpec *pspec, EphyWindow *window)
{
GtkActionGroup *action_group;
GtkAction *action;
@@ -1729,8 +1728,8 @@ sync_tab_zoom (EphyTab *tab, GParamSpec *pspec, EphyWindow *window)
if (window->priv->closing) return;
- zoom = ephy_tab_get_zoom (tab);
- type = ephy_embed_get_document_type (ephy_tab_get_embed (tab));
+ zoom = ephy_embed_get_zoom (embed);
+ type = ephy_embed_get_document_type (embed);
can_zoom = (type != EPHY_EMBED_DOCUMENT_IMAGE);
if (zoom >= ZOOM_MAXIMAL)
@@ -2173,9 +2172,6 @@ ephy_window_set_active_tab (EphyWindow *window, EphyTab *new_tab)
g_signal_handlers_disconnect_by_func (old_tab,
G_CALLBACK (sync_tab_title),
window);
- g_signal_handlers_disconnect_by_func (old_tab,
- G_CALLBACK (sync_tab_zoom),
- window);
embed = ephy_tab_get_embed (old_tab);
@@ -2185,6 +2181,10 @@ ephy_window_set_active_tab (EphyWindow *window, EphyTab *new_tab)
g_signal_handlers_disconnect_by_func (embed,
G_CALLBACK (sync_tab_document_type),
window);
+ g_signal_handlers_disconnect_by_func (embed,
+ G_CALLBACK (sync_tab_zoom),
+ window);
+
g_signal_handlers_disconnect_by_func
(embed, G_CALLBACK (tab_context_menu_cb), window);
@@ -2201,6 +2201,7 @@ ephy_window_set_active_tab (EphyWindow *window, EphyTab *new_tab)
sync_tab_security (embed, NULL, window);
sync_tab_document_type (embed, NULL, window);
+ sync_tab_zoom (embed, NULL, window);
sync_tab_address (new_tab, NULL, window);
sync_tab_icon (new_tab, NULL, window);
@@ -2211,7 +2212,6 @@ ephy_window_set_active_tab (EphyWindow *window, EphyTab *new_tab)
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);
g_signal_connect_object (new_tab, "notify::address",
G_CALLBACK (sync_tab_address),
@@ -2240,9 +2240,6 @@ ephy_window_set_active_tab (EphyWindow *window, EphyTab *new_tab)
g_signal_connect_object (new_tab, "notify::title",
G_CALLBACK (sync_tab_title),
window, 0);
- g_signal_connect_object (new_tab, "notify::zoom",
- G_CALLBACK (sync_tab_zoom),
- window, 0);
g_signal_connect_object (embed, "notify::security-level",
G_CALLBACK (sync_tab_security),
@@ -2250,6 +2247,9 @@ ephy_window_set_active_tab (EphyWindow *window, EphyTab *new_tab)
g_signal_connect_object (embed, "notify::document-type",
G_CALLBACK (sync_tab_document_type),
window, 0);
+ g_signal_connect_object (embed, "notify::zoom",
+ G_CALLBACK (sync_tab_zoom),
+ window, 0);
g_signal_connect_object (embed, "ge-context-menu",
G_CALLBACK (tab_context_menu_cb),
window, G_CONNECT_AFTER);
diff --git a/src/epiphany.defs b/src/epiphany.defs
index 37ac91b24..d9ea18035 100644
--- a/src/epiphany.defs
+++ b/src/epiphany.defs
@@ -3428,14 +3428,6 @@
(return-type "const-char*")
)
-(define-method get_zoom
- (of-object "EphyTab")
- (c-name "ephy_tab_get_zoom")
- (return-type "float")
-)
-
-
-
;; From ../../src/ephy-toolbar.h
(define-function ephy_toolbar_get_type