From beec33b028bdeb5f0da6ed51305f32e3b8041f6e Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Tue, 31 Dec 2002 11:11:13 +0000 Subject: Remove hidden filtering page. 2002-12-31 Marco Pesenti Gritti * data/glade/prefs-dialog.glade: Remove hidden filtering page. * embed/ephy-history.c: (ephy_history_autocompletion_source_foreach), (ephy_history_init), (ephy_history_add_host), (ephy_history_visited), (ephy_history_get_page_visits): * lib/ephy-autocompletion.c: (ephy_autocompletion_refine_matches), (ephy_autocompletion_update_matches_full_item): * src/bookmarks/ephy-bookmarks.c: (ephy_bookmarks_autocompletion_source_foreach): Fix memory corruption in bookmarks refine. Implement history autocompletion score. Smarter host matching code. Add some sanity checks. --- ChangeLog | 20 ++ TODO | 12 +- data/glade/prefs-dialog.glade | 518 ----------------------------------------- embed/ephy-history.c | 59 ++++- lib/ephy-autocompletion.c | 5 +- src/bookmarks/ephy-bookmarks.c | 6 +- 6 files changed, 79 insertions(+), 541 deletions(-) diff --git a/ChangeLog b/ChangeLog index aabb03f09..d5e481d10 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,23 @@ +2002-12-31 Marco Pesenti Gritti + + * data/glade/prefs-dialog.glade: + + Remove hidden filtering page. + + * embed/ephy-history.c: + (ephy_history_autocompletion_source_foreach), (ephy_history_init), + (ephy_history_add_host), (ephy_history_visited), + (ephy_history_get_page_visits): + * lib/ephy-autocompletion.c: (ephy_autocompletion_refine_matches), + (ephy_autocompletion_update_matches_full_item): + * src/bookmarks/ephy-bookmarks.c: + (ephy_bookmarks_autocompletion_source_foreach): + + Fix memory corruption in bookmarks refine. + Implement history autocompletion score. + Smarter host matching code. + Add some sanity checks. + 2002-12-31 Christian Rose * configure.in: Added "sv" to ALL_LINGUAS. diff --git a/TODO b/TODO index fb0f92c9d..e5019d541 100644 --- a/TODO +++ b/TODO @@ -1,10 +1,7 @@ To do: -- favicons doesnt work anymore -- ephy-dnd.c we still need it ? -- implement phoenix like popup blocking -- urls like www.gnome.org and gnome.org should use same folder in history -- history scoring for autocompletion +- implement phoenix like popup blocking / make popups less annoying +- drop items from history when they are not visited since some time Done: @@ -15,3 +12,8 @@ Done: * simplify/clean autocompletion entry code * favicons should not be fetched on load end * open bookmarks, close galeon -> crash +* favicons doesnt work anymore +* ephy-dnd.c we still need it ? +* autocompletion refine borked for bookmarks +* history scoring for autocompletion +* urls like www.gnome.org and gnome.org should use same folder in history diff --git a/data/glade/prefs-dialog.glade b/data/glade/prefs-dialog.glade index 4042ddbcc..d99edb7da 100644 --- a/data/glade/prefs-dialog.glade +++ b/data/glade/prefs-dialog.glade @@ -2404,524 +2404,6 @@ - - True - window2 - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - True - False - - - - 12 - True - False - 18 - - - - True - False - 6 - - - - True - <b>Cookies</b> - False - True - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - - True - False - 0 - - - - True - - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - - True - False - 6 - - - - True - True - _Always accept - True - GTK_RELIEF_NORMAL - False - False - True - - - 0 - False - False - - - - - - True - True - Accept _from current server only - True - GTK_RELIEF_NORMAL - False - False - True - cookies_radiobutton - - - 0 - False - False - - - - - - True - True - _Never accept - True - GTK_RELIEF_NORMAL - False - False - True - cookies_radiobutton - - - 0 - False - False - - - - - - True - True - _Warn before accepting a cookie - True - GTK_RELIEF_NORMAL - False - False - True - - - 0 - False - False - - - - - - True - True - Coo_kies expire at the end of the session - True - GTK_RELIEF_NORMAL - False - False - True - - - 0 - False - False - - - - - 0 - True - True - - - - - 0 - True - True - - - - - 0 - False - True - - - - - - True - False - 6 - - - - True - <b>Images</b> - False - True - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - - True - False - 0 - - - - True - - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - - True - False - 6 - - - - True - True - _Always load - True - GTK_RELIEF_NORMAL - False - False - True - - - 0 - False - False - - - - - - True - True - _Load from current server only - True - GTK_RELIEF_NORMAL - False - False - True - images_radiobutton - - - 0 - False - False - - - - - - True - True - _Never load - True - GTK_RELIEF_NORMAL - False - False - True - images_radiobutton - - - 0 - False - False - - - - - 0 - False - False - - - - - 0 - True - True - - - - - 0 - False - False - - - - - - True - False - 6 - - - - True - <b>Others</b> - False - True - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - - True - False - 0 - - - - True - - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - - True - 3 - 2 - False - 6 - 6 - - - - True - True - Allow _Java (requires plugin) - True - GTK_RELIEF_NORMAL - False - False - True - - - 0 - 1 - 1 - 2 - fill - - - - - - - True - True - Allow Java_Script - True - GTK_RELIEF_NORMAL - False - False - True - - - 0 - 1 - 2 - 3 - fill - - - - - - - True - True - Allow _popups - True - GTK_RELIEF_NORMAL - False - False - True - - - 0 - 1 - 0 - 1 - fill - - - - - - - True - True - Allow statusbar _messages - True - GTK_RELIEF_NORMAL - False - False - True - - - 1 - 2 - 0 - 1 - fill - - - - - - - True - True - _Remember passwords - True - GTK_RELIEF_NORMAL - False - False - True - - - 1 - 2 - 1 - 2 - fill - - - - - - 0 - False - False - - - - - 0 - True - True - - - - - 0 - False - False - - - - - - 6 300 diff --git a/embed/ephy-history.c b/embed/ephy-history.c index c106b274a..0511cfe67 100644 --- a/embed/ephy-history.c +++ b/embed/ephy-history.c @@ -112,29 +112,41 @@ ephy_history_autocompletion_source_set_basic_key (EphyAutocompletionSource *sour static void ephy_history_autocompletion_source_foreach (EphyAutocompletionSource *source, - const gchar *current_text, - EphyAutocompletionSourceForeachFunc func, - gpointer data) + const gchar *current_text, + EphyAutocompletionSourceForeachFunc func, + gpointer data) { GPtrArray *children; int i; EphyHistory *eb = EPHY_HISTORY (source); + GTime now; + + now = time (NULL); children = ephy_node_get_children (eb->priv->pages); for (i = 0; i < children->len; i++) { EphyNode *kid; const char *url, *title; + int last_visit, visits; + guint32 score; kid = g_ptr_array_index (children, i); + g_assert (EPHY_IS_NODE (kid)); + url = ephy_node_get_property_string (kid, EPHY_NODE_PAGE_PROP_LOCATION); title = ephy_node_get_property_string (kid, EPHY_NODE_PAGE_PROP_TITLE); + last_visit = ephy_node_get_property_int + (kid, EPHY_NODE_PAGE_PROP_LAST_VISIT); + visits = ephy_node_get_property_int + (kid, EPHY_NODE_PAGE_PROP_VISITS); + score = MAX (visits - ((now - last_visit) >> 15), 1); func (source, url, url, url, FALSE, - FALSE, 0, data); + FALSE, score, data); } ephy_node_thaw (eb->priv->pages); } @@ -308,8 +320,6 @@ ephy_history_init (EphyHistory *eb) "ephy-history.xml", NULL); - ephy_node_system_init (); - eb->priv->pages_hash = g_hash_table_new (g_str_hash, g_str_equal); eb->priv->pages_hash_lock = g_new0 (GStaticRWLock, 1); @@ -425,7 +435,27 @@ ephy_history_add_host (EphyHistory *eh, const char *url) } g_static_rw_lock_reader_lock (eh->priv->hosts_hash_lock); + host = g_hash_table_lookup (eh->priv->hosts_hash, host_name); + + if (!host) + { + char *tmp; + + if (g_str_has_prefix (host_name, "www.")) + { + tmp = g_strdup (g_utf8_offset_to_pointer (host_name, 4)); + } + else + { + tmp = g_strconcat ("www.", host_name, NULL); + } + + host = g_hash_table_lookup (eh->priv->hosts_hash, tmp); + + g_free (tmp); + } + g_static_rw_lock_reader_unlock (eh->priv->hosts_hash_lock); if (!host) @@ -452,6 +482,8 @@ 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; @@ -489,6 +521,8 @@ ephy_history_visited (EphyHistory *eh, EphyNode *node) now = time (NULL); + g_assert (EPHY_IS_NODE (node)); + url = ephy_node_get_property_string (node, EPHY_NODE_PAGE_PROP_LOCATION); @@ -525,14 +559,15 @@ ephy_history_get_page_visits (EphyHistory *gh, const char *url) { EphyNode *node; - int visits; + int visits = 0; node = ephy_history_get_page (gh, url); - - visits = ephy_node_get_property_int - (node, EPHY_NODE_PAGE_PROP_VISITS); - if (visits < 0) visits = 0; - visits++; + if (node) + { + visits = ephy_node_get_property_int + (node, EPHY_NODE_PAGE_PROP_VISITS); + if (visits < 0) visits = 0; + } return visits; } diff --git a/lib/ephy-autocompletion.c b/lib/ephy-autocompletion.c index a3f3348c1..265590003 100644 --- a/lib/ephy-autocompletion.c +++ b/lib/ephy-autocompletion.c @@ -369,8 +369,10 @@ ephy_autocompletion_refine_matches (EphyAutocompletion *ac) for (i = 0; i < oldmatches.num_matches; i++) { EphyAutocompletionMatch *mi = &oldmatches.array[i]; + if (mi->is_action || (mi->substring && g_strrstr (mi->match, p->keys[0])) || + (mi->substring && g_strrstr (mi->title, p->keys[0])) || !strncmp (key0, mi->title + mi->offset, key0l)) { acma_append (&newmatches, mi, mi->is_action); @@ -425,7 +427,8 @@ ephy_autocompletion_update_matches_full_item (EphyAutocompletionSource *source, EphyAutocompletionPrivate *p) { if (is_action || - (substring && g_strrstr (item, p->keys[0]))) + (substring && g_strrstr (item, p->keys[0])) || + (substring && g_strrstr (title, p->keys[0]))) { EphyAutocompletionMatch m; m.match = item; diff --git a/src/bookmarks/ephy-bookmarks.c b/src/bookmarks/ephy-bookmarks.c index e27a30496..2353ea7da 100644 --- a/src/bookmarks/ephy-bookmarks.c +++ b/src/bookmarks/ephy-bookmarks.c @@ -119,7 +119,6 @@ ephy_bookmarks_autocompletion_source_foreach (EphyAutocompletionSource *source, { EphyNode *kid; const char *url, *smart_url, *title, *keywords; - char *item; kid = g_ptr_array_index (children, i); url = ephy_node_get_property_string @@ -130,7 +129,6 @@ ephy_bookmarks_autocompletion_source_foreach (EphyAutocompletionSource *source, (kid, EPHY_NODE_BMK_PROP_TITLE); keywords = ephy_node_get_property_string (kid, EPHY_NODE_BMK_PROP_KEYWORDS); - item = g_strconcat (title, keywords, NULL); if (smart_url == NULL || g_utf8_strlen (smart_url, -1) == 0) @@ -139,13 +137,11 @@ ephy_bookmarks_autocompletion_source_foreach (EphyAutocompletionSource *source, } func (source, - smart_url ? NULL : item, + smart_url ? NULL : keywords, title, smart_url ? smart_url : url, (smart_url != NULL), TRUE, 0, data); - - g_free (item); } ephy_node_thaw (eb->priv->bookmarks); } -- cgit