After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 392979 - Location entry shows duplicate bookmarks and history entries
Location entry shows duplicate bookmarks and history entries
Status: RESOLVED FIXED
Product: epiphany
Classification: Core
Component: [obsolete] URL bar
git master
Other Linux
: Normal normal
: ---
Assigned To: Diego Escalante Urrelo (not reading bugmail)
Epiphany Maintainers
Depends on:
Blocks:
 
 
Reported: 2007-01-05 01:34 UTC by Diego Escalante Urrelo (not reading bugmail)
Modified: 2007-12-26 18:36 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Avoids duplicates in the location entry popup (3.81 KB, patch)
2007-01-05 01:38 UTC, Diego Escalante Urrelo (not reading bugmail)
none Details | Review
Ignore dups in completion popup (2.77 KB, patch)
2007-01-05 01:41 UTC, Diego Escalante Urrelo (not reading bugmail)
none Details | Review
Removed some comments (2.49 KB, patch)
2007-01-06 06:05 UTC, Diego Escalante Urrelo (not reading bugmail)
none Details | Review
Fixes the smart bookmarks thing. (3.60 KB, patch)
2007-01-06 23:25 UTC, Diego Escalante Urrelo (not reading bugmail)
needs-work Details | Review
Updated version (2.03 KB, patch)
2007-09-19 02:49 UTC, Diego Escalante Urrelo (not reading bugmail)
none Details | Review
20071223_bgo_392979_duped-bkmks-history (7.77 KB, patch)
2007-12-24 03:48 UTC, Diego Escalante Urrelo (not reading bugmail)
committed Details | Review
20071225_bgo_392979_duped-bkmks-history.diff: Actually filter out history entries with an existing bookmark (1.57 KB, patch)
2007-12-26 01:23 UTC, Diego Escalante Urrelo (not reading bugmail)
committed Details | Review

Description Diego Escalante Urrelo (not reading bugmail) 2007-01-05 01:34:20 UTC
1. Bookmark www.gnome.org
2. Type gnome in the location entry

What happens:
Your bookmark and your history item are displayed

What should happen:
You see only your bookmark (note that if you have gnome.org/about it is shown because it's not the same as gnome.org/)


See next comment.
Comment 1 Diego Escalante Urrelo (not reading bugmail) 2007-01-05 01:38:05 UTC
Created attachment 79420 [details] [review]
Avoids duplicates in the location entry popup

In ephy_completion_model_get_value () by if'ing I determine that the current processed node is a bookmark:

bmknode = ephy_bookmarks_find_bookmark (bookmarks, url);

Then I change the group variable to IGNORE_GROUP that comes from:

 enum
 {
        HISTORY_GROUP,
-       BOOKMARKS_GROUP
+       BOOKMARKS_GROUP,
+       IGNORE_GROUP,
+       N_GROUPS
 };

This way, the switch()'s in the init_*_col functions do the default: action instead of anything else. This way I avoid having to manage the "empty" need for this duplicated node.

It's a pretty simple hack.
Comment 2 Diego Escalante Urrelo (not reading bugmail) 2007-01-05 01:41:12 UTC
Created attachment 79421 [details] [review]
Ignore dups in completion popup

Oops, I included a ephy-window.c patch by mistake. Sorry.
This one is the clean patch.
Comment 3 Diego Escalante Urrelo (not reading bugmail) 2007-01-06 06:05:59 UTC
Created attachment 79514 [details] [review]
Removed some comments
Comment 4 Reinout van Schouwen 2007-01-06 22:37:19 UTC
Is it possible to fix #324662 too with this patch? Or would it be far more complicated?
Comment 5 Reinout van Schouwen 2007-01-06 22:44:11 UTC
Just braindumping here; sorry for the spam. There's another bug that I can't find right now that's about smart bookmarks appearing in the normal bookmarks dropdown AND in the smart bookmarks panel of the dropdown. Selecting one of those (say "Search the web") would submit %s to Google. That kind of duplicate should be eliminated as well (though maybe it's outside the scope of this bug).
Comment 6 Diego Escalante Urrelo (not reading bugmail) 2007-01-06 23:08:27 UTC
About bug #324662, the patch itself is a bit non-elegant because I couldn't find a place to iterate over the completion matches and the closest place is in lib/ instead of src/ so I couldn't use ephy-embed.h and ephy-bookmarks.h, at least as far as I understand I shouldn't.

So if I'm understanding correctly there's no way to know in advance where to put a completion option... unless there's something like insert_completion_option_at_the_top() (maybe with -1 or something like that?).


And about the smart bookmarks thing, it should be easy to do too. I'll check.
Comment 7 Diego Escalante Urrelo (not reading bugmail) 2007-01-06 23:25:57 UTC
Created attachment 79581 [details] [review]
Fixes the smart bookmarks thing.

:)
Comment 8 Christian Persch 2007-01-08 22:38:40 UTC
I'm not sure I see how this patch addresses the bug...

Shouldn't this require a modification to the _completion match function_ to just make the history entries for bookmarks be non-matches?
Comment 9 Diego Escalante Urrelo (not reading bugmail) 2007-01-18 01:16:16 UTC
I couldn't find a way of accessing the bookmark* functions from src/bookmarks/ in lib/. But that's because I lack C skills :).
Comment 10 Christian Persch 2007-01-29 21:47:55 UTC
You can't access them in lib/. If you really do need to access them, the function should move to src/.

Marking needs-work based on comment 8.
Comment 11 Diego Escalante Urrelo (not reading bugmail) 2007-04-03 14:28:15 UTC
And how do I do that? O_O
Comment 12 Christian Persch 2007-05-31 13:04:11 UTC
The ephy-location-entry.h should export a function to set the completion func, and you implement the func in ephy-completion-model.c or in ephy-location-action.c ?
Comment 13 Diego Escalante Urrelo (not reading bugmail) 2007-09-19 02:49:21 UTC
(In reply to comment #8)
> I'm not sure I see how this patch addresses the bug...
> 
> Shouldn't this require a modification to the _completion match function_ to
> just make the history entries for bookmarks be non-matches?
> 

I was looking at this again, happens that I need an EphyShell on lib/widgets/ephy-location-entry.c so I can get the bookmarks and therefore check for a matching bookmark.

I'm attaching an updated version, what is your suggestion Christian?
Comment 14 Diego Escalante Urrelo (not reading bugmail) 2007-09-19 02:49:50 UTC
Created attachment 95830 [details] [review]
Updated version
Comment 15 Diego Escalante Urrelo (not reading bugmail) 2007-12-24 03:48:35 UTC
Created attachment 101532 [details] [review]
20071223_bgo_392979_duped-bkmks-history

Moves the completion_func from lib/widgets/ephy-location-entry.c to src/ephy-location-action.c.
Adds a function to set the completion_func in lib/widgets/ephy-location-entry.c|h.

Now, about the actual bug: I'm still trying to figure out how to know for sure that the node is ONLY an history item:
	
+	bookmarks = ephy_shell_get_bookmarks (ephy_shell);
+	bmknode = ephy_bookmarks_find_bookmark (bookmarks, url);

Here I know if the url has an equivalent bookmark, now, this can be true for the bookmark and for the history item with the url of the bookmark. Hence we need another check:

+	history = ephy_history_get_pages (EPHY_HISTORY (
+					ephy_embed_shell_get_global_history (
+						embed_shell
+						)
+					)
+				);

This is stolen from ephy-completion-model.c:

static void
ephy_completion_model_get_value 
...
	group = (iter->user_data2 == model->priv->history) ?
		HISTORY_GROUP : BOOKMARKS_GROUP;

user_data2 is "root node", I don't know if that's reliable in my case... suggestions welcome!.
Comment 16 Christian Persch 2007-12-24 18:52:14 UTC
If I see this right, this patch only moves the function, without changes? If so, oktc.

How about this: if you have a history URL (HISTORY_GROUP) and find_bookmark(url) == NULL then we show this item; otherwise there'll be a bookmark for it so it'll be present again on a different row... ?
Comment 17 Diego Escalante Urrelo (not reading bugmail) 2007-12-25 23:42:44 UTC
Ok, committed the part to move the function. I'll try to have the bookmark filtering working.

------------------------------------------------------------------------
r7821 | diegoe | 2007-12-25 18:38:48 -0500 (Tue, 25 Dec 2007) | 8 lines

Moves the completion_func from lib/widgets/ephy-location-entry.c to
src/ephy-location-action.c.
Adds a function to set the completion_func in
lib/widgets/ephy-location-entry.c|h.

Part of bug #392979.
Comment 18 Diego Escalante Urrelo (not reading bugmail) 2007-12-26 01:23:29 UTC
Created attachment 101602 [details] [review]
20071225_bgo_392979_duped-bkmks-history.diff: Actually filter out history entries with an existing bookmark

Filters like this:

+	if (ephy_bookmarks_find_bookmark (bookmarks, url) != NULL &&
+	    (iter2.user_data2 == history))
+		ret = FALSE;

That reads: "if there's a bookmark for $url AND $url is in history, then skip this history entry, so the bookmark is shown".

I'm a bit worried if it's unwise to get bookmarks and history each time completion_func is called:
+	bookmarks = ephy_shell_get_bookmarks (ephy_shell);
+	history = ephy_history_get_pages (EPHY_HISTORY (
+						ephy_embed_shell_get_global_history (
+							embed_shell
+						)
+					));

Should it be catched or something?.

One last thing, this doesn't totally remove dupe'd entries, take for example google, if you type 'google.com' in the location bar you will be redirected to 'www.google.com' and then to 'www.google.com.pe' (in my case) so I'll have:
|go_________________|
 |google.com
 |www.google.com
 |Google (the bookmark'd www.google.com.pe)

For other sites like osnews.com, this doesn't happen. It's not a bug, just a nitpick we can't avoid -i think-.
Comment 19 Christian Persch 2007-12-26 18:18:42 UTC
+	history = ephy_history_get_pages (EPHY_HISTORY (
+						ephy_embed_shell_get_global_history (
+							embed_shell
+						)
+					));

Try to fit that in 2 lines :)

+	if (ephy_bookmarks_find_bookmark (bookmarks, url) != NULL &&
+	    (iter2.user_data2 == history))
+		ret = FALSE;

Should add a comment on what the idea behind this is (i.e. that we'll get the same URL again as a bookmark).

With the nits fixed, ok to commit. Thanks!
Comment 20 Diego Escalante Urrelo (not reading bugmail) 2007-12-26 18:36:38 UTC
Committed.

------------------------------------------------------------------------
r7826 | diegoe | 2007-12-26 13:32:54 -0500 (Wed, 26 Dec 2007) | 5 lines

Avoid duplicated history and bookmark entries for the same url in the 
completion popup.
Fixes bug #392979.