GNOME Bugzilla – Bug 672271
File chooser seems over-enthusiastic about using subdirectories
Last modified: 2017-08-24 22:19:32 UTC
Simple example: I want to download a file using Transmission. I have a directory structure like so: /files /foo /foo-subdir /bar /monkeys /monkeys-subdir All the files I want to download will go into one of the subdirectories of /files. I have transmission's default directory set up as /files. So I click on a torrent, Transmission opens up a dialog with a 'Destination folder' option, which defaults to /files as I specified. I want this file to go into /files/foo , so I click /files which turns into a drop-down list of recently-used folders, with 'Other' at the bottom. I click on 'Other', and the GTK+ file chooser opens up, in /files . I double-click /foo, hit Enter, and... the files wind up in /foo/foo-subdir . What the hell? It never used to do that. I don't think my actions indicated that I *wanted* it to do that. If I single-click /foo, it works, but still, this is a big change in behaviour which is *constantly* screwing me up with lots and lots of apps (the above example is just the most common case - I keep downloading files and thinking they've disappeared until I remember to look in the first named subdirectory of whatever directory I *thought* I was putting them into).
I can still reproduce it in 3.6, see also bug #673448 which looks like a duplicate (commenting here as it has a better description of the issue). See also https://bbs.archlinux.org/viewtopic.php?id=142989 I wouldn't call it just a change in behaviour though, looks like a real bug and it's pretty annoying especially with Transmission. It seems to happen only if location bar (Ctrl + L) is visible, hiding it makes everything behave as expected.
I've more or less gotten used to it by now. The 'trick' is to just _select_ the directory name, not to enter the directory. So if you want the file in /files/foo , go to /files and just click on foo/ , don't double-click it. I still forget sometimes, but...
That seems true but it cannot be achieved if e.g. you want to select a directory just from the sidebar (e.g. Videos or Downloads). If I click on Videos from the sidebar and the location bar is enabled the first directory inside Videos gets appended to the path and "single click on Videos -> Open" doesn't select Video directory but "Videos/first_sub_dir".
Yeah, I concur. I think that part is clearly a bug.
This issue is only one of two that is disruptive in my daily use of Linux as a desktop operating system. I hope it can be prioritized.
*** Bug 673448 has been marked as a duplicate of this bug. ***
I agree this is an annoyance. Really the problem is that as soon as you enter a directory which has only a single subdirectory, the file chooser automatically fills in the Location field with the name of that subdirectory. I think it should leave the Location empty in this case.
I'm still fighting this one. I've mostly trained myself for it, but here's a really annoying case I just came across. Say I add directory /foo/bar to my bookmarks, because I use it all the time. It has a subdirectory, /foo/bar/moo . If I just want to quickly save something into /foo/bar it's annoyingly inefficient, because I have to click my /foo/bar bookmark and then navigate up one level to /foo; if I just click my /foo/bar bookmark and hit "Save", the file winds up in /foo/bar/moo . Grrr.
True. As a workaround, you can add a second dummy subdirectory to /foo/bar. As I pointed out, the bug rears its head only when a directory has just one subdirectory.
Created attachment 246812 [details] [review] When selecting a folder in the file chooser entry include the current directory When selecting a folder in the file chooser entry include the current directory Otherwise we would automatically autocomplete the subdirectory, causing the wrong directory to be selected.
The analysis of "the file chooser in SELECT_FOLDER mode puts the first directory in the location entry, if there is a single directory in the folder you just entered", is correct. And while the patch in comment #10 indeed causes the file chooser's entry *not* to put the directory name in the entry, it's not completely correct. It has the side effect of introducing a filename that does not exist in the current directory. E.g. create a directory called /foo, and inside it create a subfolder called foobar. So you have foo foobar With the patch in place, when you visit the foo directory, the file chooser's entry gets populated with "foo". And once you trigger completions, you see both "foo" and "foobar" in the completion list, which is clearly wrong. The basic question is, why is the file chooser entry auto-filling the first option it finds when there is only a single subdirectory in the current directory?
And the answer is as follows. GtkFileChooserEntry creates a GtkFileSystemModel and populates it for the current folder. It does that as soon as you switch to the first subdirectory, in response to the main file chooser telling it that the base folder has changed. As soon as the model is created, it gets set on the GtkEntryCompletion. So, the GtkFileSystemModel starts loading in the background. It finishes loading, it emits "finished-loading", and the GtkFileChooserEntry explicitly asks the GtkEntryCompletion to insert the completion prefix (see the end of finished_loading_cb(), where it calls gtk_entry_completion_insert_prefix(). This is done so that *while typing*, GtkFileChooserEntry will be able to suggest a completion as soon as possible. But this bug shows that this is clearly wrong when the entry is supposed to be empty, i.e. when you just switched folders. Here is the backtrace where the completion prefix is inserted: (gdb) where
+ Trace 232124
Let me think about the right place in the code to put a check against the entry not requiring inline completion even when the file system model finishes loading...
Got it! finished_loading_cb() was causing the GtkEntryCompletion to insert the completion prefix, even if the entry didn't have the focus. You definitely want the prefix inserted while you are typing in the entry. But when the file system model is changed due to the whole file chooser changing the current folder, you don't want the prefix inserted. This is what caused the bug. I've pushed a fix to the master branch in commit 9162589b5.
Created attachment 247499 [details] [review] bgo672271.patch
Thanks much, Federico! It'd be great if this could be backported to older branches, so it doesn't annoy me for the next 12 months until all my systems are on GTK 3.10 or whatever :)
Federico: will this also fix https://bugzilla.gnome.org/show_bug.cgi?id=700321 ? if not, do you feel like tackling that one too? :)
Pushed to gtk-3-6 as commit 62f971be. Pushed to gtk-3-8 as commit 5aae1ead. (In reply to comment #16) > Federico: will this also fix https://bugzilla.gnome.org/show_bug.cgi?id=700321 > ? if not, do you feel like tackling that one too? :) That one is SUPER annoying. I think I just found a reliable way of reproducing it. I'll fix it next.
*** Bug 682047 has been marked as a duplicate of this bug. ***
Something rather similar to this seems to have come back recently (3.11.8?). Anyone else seeing it?
*** Bug 673577 has been marked as a duplicate of this bug. ***