GNOME Bugzilla – Bug 577806
gtk_file_chooser_add_shortcut_folder adds duplicates of bookmarks
Last modified: 2012-11-13 18:59:14 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:
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.
Can you provide a screenshot? What version of GTK+ do you have? I can't reproduce this.
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.
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.
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???
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.
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!