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 577806 - gtk_file_chooser_add_shortcut_folder adds duplicates of bookmarks
gtk_file_chooser_add_shortcut_folder adds duplicates of bookmarks
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkFileChooser
2.16.x
Other All
: Normal normal
: ---
Assigned To: gtk-bugs
Federico Mena Quintero
Depends on:
Blocks:
 
 
Reported: 2009-04-03 03:47 UTC by tac
Modified: 2012-11-13 18:59 UTC
See Also:
GNOME target: ---
GNOME version: 2.25/2.26


Attachments
Remove bookmark duplicate of shortcut (1.08 KB, patch)
2012-10-31 11:17 UTC, Timothy Arceri
none Details | Review

Description tac 2009-04-03 03:47:56 UTC
Please describe the problem:
when using totem "open files", some of page names in the left pane of file-picker are redundant

Steps to reproduce:
1. launch totem, press 'Ctrl+o' to start file-picker
2. confirm there are two Music folder in left pane
3. click on the second one


Actual results:
the focus gives you a jump to first one

Expected results:
I shouldn't see two folder with the same name on left pane

Does this happen every time?
yes

Other information:
Comment 1 tac 2009-04-03 07:22:01 UTC
This problem is seen when you have already had Music, Documents, ... directories under your home directory(set up by xdg-user-dirs) and you are opening file-piker in Totem.

The left pane in totem file-picker then has two same Music pages. 
Comment 2 Philip Withnall 2009-04-03 16:00:12 UTC
Can you provide a screenshot? What version of GTK+ do you have? I can't reproduce this.
Comment 3 tac 2009-04-08 03:15:58 UTC
I am using gtk+-2.16.0. I guess the real problem is how totem invokes the file-picker. In my scope, the items in left pane of open-file dialog in totem
is different with other applications. I wonder if totem could choose the setting by his own or it is aided by a guess from nautilus.
Comment 4 Philip Withnall 2009-04-08 08:10:32 UTC
Looks like a GTK+ bug. gtk_file_chooser_add_shortcut_folder will add a new shortcut folder even if it's a duplicate of an existing bookmarked folder.
Comment 5 Timothy Arceri 2012-10-30 00:41:37 UTC
From what I can make out in the code here is the problem:

gtk_file_chooser_add_shortcut_folder  is implemented in http://git.gnome.org/browse/gtk+/tree/gtk/gtkfilechooserdefault.c as

gtk_file_chooser_default_add_shortcut_folder (GtkFileChooser  *chooser,   GFile *file,  GError **error)

Priority is given to any shortcuts added by the application over any bookmarks added at construction time (see line: 8002 if (pos >= 0 && pos < shortcuts_get_index (impl, SHORTCUTS_BOOKMARKS_SEPARATOR)) )

This shows that any existing bookmarks are ignored and the shortcut is added anyway. The problem appears to be that the duplicate bookmark is not then removed. Note that if you drag and drop one of the other bookmarks than the duplicate correctly disappears. So there seems to be code on the bookmarks side that checks for duplicates, the problem is they have already been created before the shortcut is added.

I tried splitting up the above if statement and adding an else to the second condition where I attempt to remove the bookmark based on the pos but I'm having real trouble building GTK on my machine which I'm not sure I can resolve. 

The other alternative fix is to not add the shortcut if there is already a bookmark???
Comment 6 Timothy Arceri 2012-10-31 11:17:18 UTC
Created attachment 227717 [details] [review]
Remove bookmark duplicate of shortcut

Ok I figured out my build issues and I have a working patch for this bug.
Comment 7 Federico Mena Quintero 2012-11-13 18:59:14 UTC
Hi, Timothy!  Thanks for digging up this old bug and working on it.

I've pushed your patch to master, gtk-2-24, and gtk-3-6.  Thanks!