GNOME Bugzilla – Bug 302087
save-as broken
Last modified: 2011-02-04 16:18:28 UTC
Gnumeric calls gtk_file_chooser_set_current_name to set an initial entry like "statfuns". While the dialog is coming up, that is overridden by gtk+ as seen below. (gtk 2.6, cvs a week or two ago.)
+ Trace 58763
The code does... A: gtk_file_chooser_set_uri ("/uri/to/statfuns.xls"); B: gtk_file_chooser_unselect_all (); C: gtk_file_chooser_set_current_name ("statfuns"); The problem is that the default file chooser uses an async mechanism to do A in such a way that it ends up being done after C. Further, B clearly needs to be just as async as A, but it is in fact done synchronously!
*** This bug has been marked as a duplicate of 165264 ***
Indeed - we need to clear the list of pending selections when someone calls unselect_all(). Or something like that. I'll look into it.
*** Bug 302563 has been marked as a duplicate of this bug. ***
From a quick look at the code, it seems like we need to cancel the pending selections both in unselect_all() and set_current_name(). Note that pending_select_paths_process() will select the first row iff the list of pending selections is empty, the widget is mapped, and it is in OPEN mode. What if you do gtk_file_chooser_dialog_new(); gtk_file_chooser_set_current_folder(); ... this starts loading asynchronously gtk_file_chooser_select_filename(); gtk_file_chooser_unselect_all(); gtk_widget_show (file_chooser); ... finishes loading; first row gets selected Maybe it's a corner case, but maybe we also need a flag that says "you should really not select anything" for when pending_select_paths_process() gets finally called.
The documentation for all this is written as-if everything is synchroneous and I think that is good. It is a good reference for deciding what the above code should do. I think the basic problem is that you cannot do half the things asynchroneously without getting weird effects. From a least-surprise point of view, the async code should never do anything that interferes with the GUI user, i.e., once the user starts moving around and selecting stuff, the async code should keep its little fingers away.
*** Bug 307378 has been marked as a duplicate of this bug. ***
Created attachment 47783 [details] [review] This is the patch I'm using This is the patch I'll commit.
Committed to gtk-2-6 and HEAD. 2005-06-14 Federico Mena Quintero <federico@ximian.com> Fix #302087: * gtk/gtkfilechooserdefault.c (list_selection_changed): Emit "selection-changed" and do the normal housekeeping even if we are in SAVE mode and there is nothing selected. We didn't emit that signal if we were in SAVE mode and unselect_all() got called. (gtk_file_chooser_default_unselect_all): Call pending_select_paths_free() so that we cancel any asynchronous selections. (gtk_file_chooser_default_set_current_name): Likewise.