GNOME Bugzilla – Bug 320295
FileChooser save dialog doesn't use filters for autocomplete
Last modified: 2018-02-10 04:36:40 UTC
Distribution/Version: FC4 I have a FileChooser with several filters applied. I have chosen a default filter (it filters on the pattern *.cols). When I use the filename entry box it matches on every file in the directory, not just the ones that have the .cols extension. It is my opinion that it should only autocomplete on those filenames, if a user wishes to autocomplete on all filenames, they should expand the dialog and change the filter.
Hmm, this is debatable. I'd love to see how it works in practice. Want to cook a patch? I can point you to the relevant code.
I could try making a patch. Where should I start? :) Please point me to the code that would need to be patched as well as the code that filters the file display. Thank you!
The main code for the file chooser is gtk+/gtk/gtkfilechooserdefault.c. The entry with completion is in gtk+/gtk/gtkfilechooserentry.c.
In gtkfilechooserentry.c, you may want to start by reading the functions start_autocompletion() and start_explicit_completion(), and start_loading_current_folder(). Right now GtkFileChooserEntry doesn't know which filter the file chooser is using; you would need to communicate the filter to the entry. The function populate_completion_store() is where the current folder is finished loading, and the entry looks at the files to build the completion list. There, the entry creates its own GtkListStore and puts file info in it. You *may* want to see if you can use a GtkFileSystemModel instead of that home-grown code to read directories and populate list stores, as GtkFileSystemModel is much faster and smarter about filtering in general.
OK, Federico, I've taken my first look at the code. I'm not a gnome developer so my patch--if I made one--would be trash I'm sure. Is your goal for the patch just to see if you like the behavior? If so, I can hack that up, but don't count on my for good design. (Especially regarding how to make the FileChooserEntry aware of the filter.)
Don't worry about the quality of your first patch; we can polish it later. Yeah, I'd like to see how the file chooser feels with that behavior... I *think* completion should show you all the files, not just the filtered ones (as you are typing things explicitly instead of just picking from a file list), but let's see how that goes. To make the entry aware of the filter, you can simply add a gtk_file_chooser_entry_set_filter(entry, filter) function.
I guess this has become apparent, but I think this patch would be a little over my head since I haven't done much GTK programming (even at the consumption level). Sorry for dropping the ball.
We're moving to gitlab! As part of this move, we are closing bugs that haven't seen activity in more than 5 years. If this issue is still imporant to you and still relevant with GTK+ 3.22 or master, please consider creating a gitlab issue for it.