GNOME Bugzilla – Bug 353196
Add a file-set signal to GtkFileChooserButton
Last modified: 2011-02-04 16:11:01 UTC
It would be very nice to have a file-set signal on GtkFileChooserButtons, just as we have color-set on color buttons and so on. Otherwise, it's a bit awkward to code, say, an instant apply preference dialog using a file chooser button.
Created attachment 71754 [details] [review] Add a file-set signal to GtkFileChooserButton
Makes sense to me. class->file_set = NULL; is not necessary, and the signal needs some actual docs. Other than that, it looks fine.
Yes, this would be very useful. Right now people abuse "selection-changed", which is just not for that. Alternatively, GtkFileChooserButton could simply *not* proxy that signal unless the dialog has just been closed.
Created attachment 71801 [details] [review] Essentially the same patch, upto Matthias's comment #2. This new patch does not set G_SIGNAL_ACTION on the signal. This also corrects a typo in the documentation for GtkFileChooser::update-preview.
Fixed on HEAD: 2006-12-26 Mariano Suárez-Alvarez <mariano@gnome.org> * gtk/gtkfilechooserbuuton.[hc]: Add a file-set signal to the filechooser button. Bug 353196.
Just a follow up to this. It seems that the documentation for this signal isn't generating properly. Neither library.gnome.org or the packaged GTK+ 2.12 docs (from Debian) pick up the documentation for this signal.
This should fix the problem with the documentation: 2008-03-03 Sven Neumann <sven@gimp.org> * gtk/gtkfilechooserbutton.c (G_DEFINE_TYPE_WITH_CODE): fixed a typo in the documentation of the GtkFileChooserButtons::file-set signal (see bug #353196).
Has anyone noticed that 'file-set' is triggered regardless of whether 'Ok' or 'Cancel' has been pressed in the dialog? Even worse, when pressing 'Cancel' gtk_file_chooser_get_filename also reports the filename last selected. Here is how to reproduce: 1. Compile and run the attached test case. 2. Press the file chooser button, select a filename and press 'Ok', 3. Press the file chooser button again, select a different filename and press 'Cancel'. The output received is something like: Received 'file-set', filename: '/etc/vimrc' Received 'file-set', filename: '/etc/yp.conf' While the first output is correct, I would expect no 'file-set' triggered and thus no output for line 3.
Created attachment 110258 [details] Test case for file-set bug
Forgot to mention that this happens with gtk2-2.12.5-1.fc8
Why was this new signal marked as G_SIGNAL_ACTION? That's normally for key-binding signals, right?
Just an oversight, I guess. In comment 4, Mariano said: This new patch does not set G_SIGNAL_ACTION on the signal. But in fact, his patch still did... So, this should be removed.