GNOME Bugzilla – Bug 612235
User cannot clear chosen file.
Last modified: 2018-05-02 14:52:48 UTC
In my VPN client configuration (in NetworkManager-openconnect), I have an _optional_ CA certificate file option. When you start off, it says (None) and no file is selected. If you select a file, there seems to be no way to get back to that original, empty, state. I could put a separate 'clear' button into the UI which will clear the contents of the file chooser, but that sucks. Please advise.
A "Clear" button seems to be the existing practice. It's what (e.g.) Evolution does to let you add/remove icons to categories. You can use gtk_file_chooser_unselect_all() on the GtkFileChooserButton, and it will go back to saying "None". See bug #563010 for discussion about this. The file chooser button *could* have an API to make it show an extra "None" option in a drop-down menu, and/or an "I don't want anything" button in the dialog. Proposals/patches welcome :)
It's kind of fuckeder than that. If you go to edit a VPN connection where a file is already set (i.e. we've called gtk_file_chooser_set_filename()) to set it to something non-empty), then the user _can_ clear it to read '(None)' by clicking to open the file chooser, then hitting cancel. However, the 'selection-changed' callback doesn't get invoked. But if the user then changes something _else_, then the new configuration does actually get saved. This only works once, though. Once the user selects a file through the UI, the trick of opening the file dialog and then hitting 'cancel' will no longer work. Until we destroy the window and start again.
Clearing the button by hitting Cancel should not happen. That's a bug. As for "only works once", this sounds like a bug we had where the file chooser button had an incorrect idea of what state it was in... sadly I don't remember the exact bug. I don't have time to work on this right now; do you think you could track it down?
*** Bug 760699 has been marked as a duplicate of this bug. ***
There IS a way to do this: Simply hold the Ctrl key and click on the folder again. (This does not depend on multiple-selection mode.) That is easy and intuitive enough to me, though I appreciate that may not be the same for other users who don't use keynav so preferentially.
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/gtk/issues/332.