After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 302087 - save-as broken
save-as broken
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkFileChooser
2.6.x
Other All
: Normal normal
: ---
Assigned To: Federico Mena Quintero
Federico Mena Quintero
: 302563 307378 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2005-04-26 20:26 UTC by Morten Welinder
Modified: 2011-02-04 16:18 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
This is the patch I'm using (1.49 KB, patch)
2005-06-15 01:01 UTC, Federico Mena Quintero
committed Details | Review

Description Morten Welinder 2005-04-26 20:26:24 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.)


  • #0 _gtk_file_chooser_entry_set_file_part
    at gtkfilechooserentry.c line 950
  • #1 update_chooser_entry
    at gtkfilechooserdefault.c line 4719
  • #2 list_selection_changed
    at gtkfilechooserdefault.c line 5883
  • #3 g_cclosure_marshal_VOID__VOID
    at gmarshal.c line 77
  • #4 g_closure_invoke
    at gclosure.c line 437
  • #5 signal_emit_unlocked_R
    at gsignal.c line 2488
  • #6 g_signal_emit_valist
    at gsignal.c line 2247
  • #7 g_signal_emit
    at gsignal.c line 2291
  • #8 _gtk_tree_selection_internal_select_node
    at gtktreeselection.c line 1511
  • #9 gtk_tree_selection_select_path
    at gtktreeselection.c line 798
  • #10 gtk_tree_selection_select_iter
    at gtktreeselection.c line 866
  • #11 select_func
    at gtkfilechooserdefault.c line 4828
  • #12 _gtk_file_system_model_path_do
    at gtkfilesystemmodel.c line 1155
  • #13 show_and_select_paths
    at gtkfilechooserdefault.c line 4577
  • #14 pending_select_paths_process
    at gtkfilechooserdefault.c line 4595
  • #15 browse_files_model_finished_loading_cb
    at gtkfilechooserdefault.c line 4645
  • #16 g_cclosure_marshal_VOID__VOID
    at gmarshal.c line 77
  • #17 g_closure_invoke
    at gclosure.c line 437
  • #18 signal_emit_unlocked_R
    at gsignal.c line 2488
  • #19 g_signal_emit_valist
    at gsignal.c line 2247
  • #20 g_signal_emit
    at gsignal.c line 2291
  • #21 idle_finished_loading_cb
    at gtkfilesystemmodel.c line 688
  • #22 source_closure_marshal_BOOLEAN__VOID
    at gsourceclosure.c line 81
  • #23 g_closure_invoke
    at gclosure.c line 437
  • #24 source_closure_callback
    at gsourceclosure.c line 123
  • #25 g_idle_dispatch
    at gmain.c line 3812
  • #26 g_main_dispatch
    at gmain.c line 1933
  • #27 g_main_context_dispatch
    at gmain.c line 2483
  • #28 g_main_context_iterate
    at gmain.c line 2564
  • #29 g_main_loop_run
    at gmain.c line 2768
  • #30 gtk_main
    at gtkmain.c line 963

Comment 1 Morten Welinder 2005-04-28 15:06:32 UTC
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!
Comment 2 Federico Mena Quintero 2005-04-28 20:10:51 UTC

*** This bug has been marked as a duplicate of 165264 ***
Comment 3 Federico Mena Quintero 2005-04-29 16:53:00 UTC
Indeed - we need to clear the list of pending selections when someone calls
unselect_all().  Or something like that.  I'll look into it.
Comment 4 Morten Welinder 2005-05-03 13:15:32 UTC
*** Bug 302563 has been marked as a duplicate of this bug. ***
Comment 5 Federico Mena Quintero 2005-06-10 20:28:48 UTC
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.
Comment 6 Morten Welinder 2005-06-13 16:31:50 UTC
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.
Comment 7 Federico Mena Quintero 2005-06-13 21:21:23 UTC
*** Bug 307378 has been marked as a duplicate of this bug. ***
Comment 8 Federico Mena Quintero 2005-06-15 01:01:00 UTC
Created attachment 47783 [details] [review]
This is the patch I'm using

This is the patch I'll commit.
Comment 9 Federico Mena Quintero 2005-06-15 01:10:33 UTC
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.