aboutsummaryrefslogtreecommitdiffstats
path: root/embed
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@it.gnome.org>2003-01-14 03:01:47 +0800
committerMarco Pesenti Gritti <mpeseng@src.gnome.org>2003-01-14 03:01:47 +0800
commitafb43e43599602fba8c1b9178d17c1a8a14867e1 (patch)
tree5eced0804590fb82c67a9b783e2095d9ebd3f065 /embed
parent9ff4f5f92f9db92f4b420430d6368feabc26490b (diff)
downloadgsoc2013-epiphany-afb43e43599602fba8c1b9178d17c1a8a14867e1.tar
gsoc2013-epiphany-afb43e43599602fba8c1b9178d17c1a8a14867e1.tar.gz
gsoc2013-epiphany-afb43e43599602fba8c1b9178d17c1a8a14867e1.tar.bz2
gsoc2013-epiphany-afb43e43599602fba8c1b9178d17c1a8a14867e1.tar.lz
gsoc2013-epiphany-afb43e43599602fba8c1b9178d17c1a8a14867e1.tar.xz
gsoc2013-epiphany-afb43e43599602fba8c1b9178d17c1a8a14867e1.tar.zst
gsoc2013-epiphany-afb43e43599602fba8c1b9178d17c1a8a14867e1.zip
Use the title also for hosts in history. Cleanup hosts matching code a
2003-01-13 Marco Pesenti Gritti <marco@it.gnome.org> * embed/ephy-history.c: (ephy_history_save), (hosts_added_cb), (hosts_removed_cb), (ephy_history_finalize), (ephy_history_host_set_title), (ephy_history_host_visited), (ephy_history_add_host), (ephy_history_visited), (ephy_history_add_page), (ephy_history_set_page_title): * src/ephy-history-model.c: (ephy_history_model_get_value): * src/ephy-shell.c: (ephy_shell_get_autocompletion): Use the title also for hosts in history. Cleanup hosts matching code a lot.
Diffstat (limited to 'embed')
-rw-r--r--embed/ephy-history.c175
1 files changed, 121 insertions, 54 deletions
diff --git a/embed/ephy-history.c b/embed/ephy-history.c
index 3df30b109..2d5944737 100644
--- a/embed/ephy-history.c
+++ b/embed/ephy-history.c
@@ -270,7 +270,7 @@ ephy_history_save (EphyHistory *eb)
GPtrArray *children;
int i;
- LOG ("Saving history\n")
+ LOG ("Saving history")
/* save nodes to xml */
xmlIndentTreeOutput = TRUE;
@@ -313,7 +313,7 @@ hosts_added_cb (EphyNode *node,
g_static_rw_lock_writer_lock (eb->priv->hosts_hash_lock);
g_hash_table_insert (eb->priv->hosts_hash,
- (char *) ephy_node_get_property_string (child, EPHY_NODE_PAGE_PROP_TITLE),
+ (char *) ephy_node_get_property_string (child, EPHY_NODE_PAGE_PROP_LOCATION),
child);
g_static_rw_lock_writer_unlock (eb->priv->hosts_hash_lock);
@@ -327,7 +327,7 @@ hosts_removed_cb (EphyNode *node,
g_static_rw_lock_writer_lock (eb->priv->hosts_hash_lock);
g_hash_table_remove (eb->priv->hosts_hash,
- ephy_node_get_property_string (child, EPHY_NODE_PAGE_PROP_TITLE));
+ ephy_node_get_property_string (child, EPHY_NODE_PAGE_PROP_LOCATION));
g_static_rw_lock_writer_unlock (eb->priv->hosts_hash_lock);
}
@@ -450,6 +450,8 @@ ephy_history_finalize (GObject *object)
g_free (eb->priv);
+ LOG ("Global history finalized");
+
G_OBJECT_CLASS (parent_class)->finalize (object);
}
@@ -463,49 +465,105 @@ ephy_history_new ()
return tab;
}
+static void
+ephy_history_host_set_title (EphyHistory *eh,
+ EphyNode *host,
+ EphyNode *page,
+ const char *title)
+{
+ const char *real_url;
+ const char *host_url;
+ GValue value = { 0, };
+
+ real_url = ephy_node_get_property_string
+ (page, EPHY_NODE_PAGE_PROP_LOCATION);
+ host_url = ephy_node_get_property_string
+ (host, EPHY_NODE_PAGE_PROP_LOCATION);
+
+ if (strcmp (real_url, host_url) == 0)
+ {
+
+ g_value_init (&value, G_TYPE_STRING);
+ g_value_set_string (&value, title);
+ ephy_node_set_property (host, EPHY_NODE_PAGE_PROP_TITLE,
+ &value);
+ g_value_unset (&value);
+ }
+}
+
+static void
+ephy_history_host_visited (EphyHistory *eh,
+ EphyNode *host,
+ GTime now)
+{
+ GValue value = { 0, };
+ int visits;
+
+ visits = ephy_node_get_property_int
+ (host, EPHY_NODE_PAGE_PROP_VISITS);
+ if (visits < 0) visits = 0;
+ visits++;
+
+ g_value_init (&value, G_TYPE_INT);
+ g_value_set_int (&value, visits);
+ ephy_node_set_property (host, EPHY_NODE_PAGE_PROP_VISITS,
+ &value);
+ g_value_unset (&value);
+
+ g_value_init (&value, G_TYPE_INT);
+ g_value_set_int (&value, now);
+ ephy_node_set_property (host, EPHY_NODE_PAGE_PROP_LAST_VISIT,
+ &value);
+ g_value_unset (&value);
+}
+
static EphyNode *
-ephy_history_add_host (EphyHistory *eh, const char *url)
+ephy_history_add_host (EphyHistory *eh, EphyNode *page)
{
- EphyNode *host;
GnomeVFSURI *vfs_uri = NULL;
+ EphyNode *host = NULL;
const char *host_name = NULL;
- char *host_location = NULL;
- GTime now;
+ GList *host_locations = NULL, *l;
GValue value = { 0, };
- int visits;
+ const char *url;
+ const char *scheme = NULL;
+ GTime now;
now = time (NULL);
+ url = ephy_node_get_property_string
+ (page, EPHY_NODE_PAGE_PROP_LOCATION);
+
+ vfs_uri = gnome_vfs_uri_new (url);
+
+ if (vfs_uri)
+ {
+ scheme = gnome_vfs_uri_get_scheme (vfs_uri);
+ host_name = gnome_vfs_uri_get_host_name (vfs_uri);
+ }
+
/* Build an host name */
- if (!g_ascii_strncasecmp (url, "file://", 7))
+ if (scheme == NULL || host_name == NULL)
+ {
+ host_name = _("Others");
+ host_locations = g_list_append (host_locations,
+ g_strdup ("about:blank"));
+ }
+ else if (strcmp (url, "file") == 0)
{
host_name = _("Local files");
- host_location = g_strdup ("file://");
+ host_locations = g_list_append (host_locations,
+ g_strdup ("file:///"));
}
else
{
- vfs_uri = gnome_vfs_uri_new (url);
- if (vfs_uri != NULL)
- {
- host_name = gnome_vfs_uri_get_host_name (vfs_uri);
- host_location = gnome_vfs_uri_to_string
- (vfs_uri, GNOME_VFS_URI_HIDE_FRAGMENT_IDENTIFIER);
- }
-
- if (host_name == NULL)
- {
- host_name = _("Other");
- host_location = g_strdup ("about:blank");
- }
- }
-
- g_static_rw_lock_reader_lock (eh->priv->hosts_hash_lock);
+ char *location;
+ char *tmp;
- host = g_hash_table_lookup (eh->priv->hosts_hash, host_name);
+ location = g_strconcat (gnome_vfs_uri_get_scheme (vfs_uri),
+ "://", host_name, "/", NULL);
+ host_locations = g_list_append (host_locations, location);
- if (!host)
- {
- char *tmp;
if (g_str_has_prefix (host_name, "www."))
{
@@ -515,12 +573,22 @@ ephy_history_add_host (EphyHistory *eh, const char *url)
{
tmp = g_strconcat ("www.", host_name, NULL);
}
-
- host = g_hash_table_lookup (eh->priv->hosts_hash, tmp);
-
+ location = g_strconcat (gnome_vfs_uri_get_scheme (vfs_uri),
+ "://", tmp, "/", NULL);
g_free (tmp);
+ host_locations = g_list_append (host_locations, location);
}
+ g_return_val_if_fail (host_locations != NULL, NULL);
+
+ g_static_rw_lock_reader_lock (eh->priv->hosts_hash_lock);
+
+ for (l = host_locations; l != NULL; l = l->next)
+ {
+ host = g_hash_table_lookup (eh->priv->hosts_hash,
+ (char *)l->data);
+ if (host) break;
+ }
g_static_rw_lock_reader_unlock (eh->priv->hosts_hash_lock);
if (!host)
@@ -533,7 +601,7 @@ ephy_history_add_host (EphyHistory *eh, const char *url)
g_value_unset (&value);
g_value_init (&value, G_TYPE_STRING);
- g_value_set_string (&value, host_location);
+ g_value_set_string (&value, (char *)host_locations->data);
ephy_node_set_property (host, EPHY_NODE_PAGE_PROP_LOCATION,
&value);
g_value_unset (&value);
@@ -547,31 +615,15 @@ ephy_history_add_host (EphyHistory *eh, const char *url)
ephy_node_add_child (eh->priv->hosts, host);
}
- g_assert (EPHY_IS_NODE (host));
-
- visits = ephy_node_get_property_int
- (host, EPHY_NODE_PAGE_PROP_VISITS);
- if (visits < 0) visits = 0;
- visits++;
-
- g_value_init (&value, G_TYPE_INT);
- g_value_set_int (&value, visits);
- ephy_node_set_property (host, EPHY_NODE_PAGE_PROP_VISITS,
- &value);
- g_value_unset (&value);
-
- g_value_init (&value, G_TYPE_INT);
- g_value_set_int (&value, now);
- ephy_node_set_property (host, EPHY_NODE_PAGE_PROP_LAST_VISIT,
- &value);
- g_value_unset (&value);
+ ephy_history_host_visited (eh, host, now);
if (vfs_uri)
{
gnome_vfs_uri_unref (vfs_uri);
}
- g_free (host_location);
+ g_list_foreach (host_locations, (GFunc)g_free, NULL);
+ g_list_free (host_locations);
return host;
}
@@ -583,6 +635,7 @@ ephy_history_visited (EphyHistory *eh, EphyNode *node)
GTime now;
int visits;
const char *url;
+ int host_id;
now = time (NULL);
@@ -613,6 +666,12 @@ ephy_history_visited (EphyHistory *eh, EphyNode *node)
}
g_value_unset (&value);
+ host_id = ephy_node_get_property_int (node, EPHY_NODE_PAGE_PROP_HOST_ID);
+ if (host_id >= 0)
+ {
+ ephy_history_host_visited (eh, ephy_node_get_from_id (host_id), now);
+ }
+
eh->priv->last_page = node;
g_signal_emit (G_OBJECT (eh), ephy_history_signals[VISITED], 0, url);
@@ -661,7 +720,7 @@ ephy_history_add_page (EphyHistory *eb,
&value);
g_value_unset (&value);
- host = ephy_history_add_host (eb, url);
+ host = ephy_history_add_host (eb, bm);
g_value_init (&value, G_TYPE_INT);
g_value_set_int (&value, ephy_node_get_id (host));
@@ -701,6 +760,7 @@ ephy_history_set_page_title (EphyHistory *gh,
const char *title)
{
EphyNode *node;
+ guint host_id;
node = ephy_history_get_page (gh, url);
if (node)
@@ -713,6 +773,13 @@ ephy_history_set_page_title (EphyHistory *gh,
(node, EPHY_NODE_PAGE_PROP_TITLE, &value);
g_value_unset (&value);
}
+
+ host_id = ephy_node_get_property_int (node, EPHY_NODE_PAGE_PROP_HOST_ID);
+ if (host_id >= 0)
+ {
+ ephy_history_host_set_title (gh, ephy_node_get_from_id (host_id),
+ node, title);
+ }
}
void