aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2003-10-30 03:49:38 +0800
committerChristian Persch <chpe@src.gnome.org>2003-10-30 03:49:38 +0800
commitdd37d52cd37c158e9a6219163336b25b90a33764 (patch)
tree73dde9aa809c4202486eac659996b766e991a5da
parentcc10162908abf03fe5e1998d5cee1b41f21e791c (diff)
downloadgsoc2013-epiphany-dd37d52cd37c158e9a6219163336b25b90a33764.tar
gsoc2013-epiphany-dd37d52cd37c158e9a6219163336b25b90a33764.tar.gz
gsoc2013-epiphany-dd37d52cd37c158e9a6219163336b25b90a33764.tar.bz2
gsoc2013-epiphany-dd37d52cd37c158e9a6219163336b25b90a33764.tar.lz
gsoc2013-epiphany-dd37d52cd37c158e9a6219163336b25b90a33764.tar.xz
gsoc2013-epiphany-dd37d52cd37c158e9a6219163336b25b90a33764.tar.zst
gsoc2013-epiphany-dd37d52cd37c158e9a6219163336b25b90a33764.zip
Add public function to get a host node from a page url.
2003-10-29 Christian Persch <chpe@cvs.gnome.org> * embed/ephy-history.c: (ephy_history_add_host), (ephy_history_get_host): * embed/ephy-history.h: Add public function to get a host node from a page url. * src/ephy-tab.c: (address_has_web_scheme), (ephy_tab_address_cb), (ephy_tab_zoom_changed_cb), (open_link_in_new_tab), (ephy_tab_init): Persist zoom settings per host.
-rw-r--r--ChangeLog14
-rw-r--r--embed/ephy-history.c17
-rw-r--r--embed/ephy-history.h6
-rw-r--r--src/ephy-tab.c106
4 files changed, 123 insertions, 20 deletions
diff --git a/ChangeLog b/ChangeLog
index f175838aa..7ed450c41 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2003-10-29 Christian Persch <chpe@cvs.gnome.org>
+
+ * embed/ephy-history.c: (ephy_history_add_host),
+ (ephy_history_get_host):
+ * embed/ephy-history.h:
+
+ Add public function to get a host node from a page url.
+
+ * src/ephy-tab.c: (address_has_web_scheme), (ephy_tab_address_cb),
+ (ephy_tab_zoom_changed_cb), (open_link_in_new_tab),
+ (ephy_tab_init):
+
+ Persist zoom settings per host.
+
2003-10-29 Soren Sandmann <sandmann@daimi.au.dk>
* lib/egg/egg-editable-toolbar.c: (drag_data_received_cb),
diff --git a/embed/ephy-history.c b/embed/ephy-history.c
index 197ad85d3..1c4cb3b28 100644
--- a/embed/ephy-history.c
+++ b/embed/ephy-history.c
@@ -536,19 +536,28 @@ ephy_history_host_visited (EphyHistory *eh,
static EphyNode *
ephy_history_add_host (EphyHistory *eh, EphyNode *page)
{
+ const char *url;
+
+ url = ephy_node_get_property_string
+ (page, EPHY_NODE_PAGE_PROP_LOCATION);
+
+ return ephy_history_get_host (eh, url);
+}
+
+EphyNode *
+ephy_history_get_host (EphyHistory *eh, const char *url)
+{
GnomeVFSURI *vfs_uri = NULL;
EphyNode *host = NULL;
const char *host_name = NULL;
GList *host_locations = NULL, *l;
GValue value = { 0, };
- const char *url;
const char *scheme = NULL;
GTime now;
- now = time (NULL);
+ g_return_val_if_fail (url != NULL, NULL);
- url = ephy_node_get_property_string
- (page, EPHY_NODE_PAGE_PROP_LOCATION);
+ now = time (NULL);
vfs_uri = gnome_vfs_uri_new (url);
diff --git a/embed/ephy-history.h b/embed/ephy-history.h
index 80565aba7..52948b65c 100644
--- a/embed/ephy-history.h
+++ b/embed/ephy-history.h
@@ -45,7 +45,8 @@ enum
EPHY_NODE_PAGE_PROP_FIRST_VISIT = 6,
EPHY_NODE_PAGE_PROP_HOST_ID = 7,
EPHY_NODE_PAGE_PROP_PRIORITY = 8,
- EPHY_NODE_PAGE_PROP_ICON = 9
+ EPHY_NODE_PAGE_PROP_ICON = 9,
+ EPHY_NODE_HOST_PROP_ZOOM = 10
};
struct EphyHistory
@@ -67,6 +68,9 @@ EphyHistory *ephy_history_new (void);
EphyNode *ephy_history_get_hosts (EphyHistory *gh);
+EphyNode *ephy_history_get_host (EphyHistory *gh,
+ const char *url);
+
EphyNode *ephy_history_get_pages (EphyHistory *gh);
EphyNode *ephy_history_get_page (EphyHistory *gh,
diff --git a/src/ephy-tab.c b/src/ephy-tab.c
index 4db7b43c1..5da504146 100644
--- a/src/ephy-tab.c
+++ b/src/ephy-tab.c
@@ -73,6 +73,7 @@ struct EphyTabPrivate
int height;
GtkToggleAction *action;
float zoom;
+ gboolean setting_zoom;
EmbedSecurityLevel security_level;
TabNavigationFlags nav_flags;
};
@@ -391,6 +392,29 @@ ephy_tab_finalize (GObject *object)
LOG ("EphyTab finalized %p", tab)
}
+static gboolean
+address_has_web_scheme (const char *address)
+{
+ GnomeVFSURI *uri;
+ const char *scheme;
+ gboolean has_web_scheme = FALSE;
+
+ uri = gnome_vfs_uri_new (address);
+ if (uri != NULL)
+ {
+ scheme = gnome_vfs_uri_get_scheme (uri);
+
+ has_web_scheme = (strcmp (scheme, "http") == 0 ||
+ strcmp (scheme, "https") == 0 ||
+ strcmp (scheme, "ftp") == 0 ||
+ strcmp (scheme, "file") == 0);
+
+ gnome_vfs_uri_unref (uri);
+ }
+
+ return has_web_scheme;
+}
+
/* Public functions */
EphyTab *
@@ -569,6 +593,8 @@ ephy_tab_link_message_cb (EphyEmbed *embed,
static void
ephy_tab_address_cb (EphyEmbed *embed, const char *address, EphyTab *tab)
{
+ LOG ("ephy_tab_address_cb tab %p address %s", tab, address)
+
if (tab->priv->address_expire == TAB_ADDRESS_EXPIRE_NOW)
{
ephy_tab_set_location (tab, address, TAB_ADDRESS_EXPIRE_NOW);
@@ -577,12 +603,74 @@ 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);
+
+ /* restore zoom level */
+ if (address_has_web_scheme (address))
+ {
+ EphyHistory *history;
+ EphyNode *host;
+ GValue value = { 0, };
+ float zoom = 1.0, current_zoom = 1.0;
+ gresult rv;
+
+ history = ephy_embed_shell_get_global_history
+ (EPHY_EMBED_SHELL (ephy_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);
+ }
+
+ rv = ephy_embed_zoom_get (embed, &current_zoom);
+ if (rv == G_OK && zoom != current_zoom)
+ {
+ tab->priv->setting_zoom = TRUE;
+ ephy_embed_zoom_set (embed, zoom, FALSE);
+ tab->priv->setting_zoom = FALSE;
+ }
+ }
}
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->setting_zoom)
+ {
+ return;
+ }
+
+ ephy_embed_get_location (embed, TRUE, &address);
+ if (address_has_web_scheme (address))
+ {
+ EphyHistory *history;
+ EphyNode *host;
+ GValue value = { 0, };
+ float zoom = 1.0;
+
+ history = ephy_embed_shell_get_global_history
+ (EPHY_EMBED_SHELL (ephy_shell));
+ host = ephy_history_get_host (history, address);
+
+ if (host != NULL && ephy_embed_zoom_get (embed, &zoom) == G_OK)
+ {
+ g_value_init (&value, G_TYPE_FLOAT);
+ g_value_set_float (&value, zoom);
+ ephy_node_set_property
+ (host, EPHY_NODE_HOST_PROP_ZOOM, &value);
+ g_value_unset (&value);
+ }
+ }
+
+ g_free (address);
}
static void
@@ -885,26 +973,13 @@ static void
open_link_in_new_tab (EphyTab *tab,
const char *link_address)
{
- GnomeVFSURI *uri;
- const char *scheme;
EphyWindow *window;
- gboolean new_tab = FALSE;
+ gboolean new_tab;
window = ephy_tab_get_window (tab);
g_return_if_fail (window != NULL);
- uri = gnome_vfs_uri_new (link_address);
- if (uri != NULL)
- {
- scheme = gnome_vfs_uri_get_scheme (uri);
-
- new_tab = (strcmp (scheme, "http") == 0 ||
- strcmp (scheme, "https") == 0 ||
- strcmp (scheme, "ftp") == 0 ||
- strcmp (scheme, "file") == 0);
-
- gnome_vfs_uri_unref (uri);
- }
+ new_tab = address_has_web_scheme (link_address);
if (new_tab)
{
@@ -1000,6 +1075,7 @@ ephy_tab_init (EphyTab *tab)
tab->priv->security_level = STATE_IS_UNKNOWN;
tab->priv->status_message = NULL;
tab->priv->zoom = 1.0;
+ tab->priv->setting_zoom = FALSE;
tab->priv->address_expire = TAB_ADDRESS_EXPIRE_NOW;
tab->priv->embed = ephy_embed_new (G_OBJECT(single));