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 499653 - FileChooserButton select random file on cancel
FileChooserButton select random file on cancel
Status: RESOLVED DUPLICATE of bug 691040
Product: gtk+
Classification: Platform
Component: Widget: GtkFileChooser
2.12.x
Other All
: Normal minor
: ---
Assigned To: gtk-bugs
Federico Mena Quintero
Depends on:
Blocks:
 
 
Reported: 2007-11-26 02:13 UTC by Colomban Wendling
Modified: 2013-09-23 20:54 UTC
See Also:
GNOME target: ---
GNOME version: 2.19/2.20


Attachments
disable selection-changed handling (2.72 KB, patch)
2007-11-27 21:55 UTC, Luca Bruno
none Details | Review

Description Colomban Wendling 2007-11-26 02:13:30 UTC
Please describe the problem:
If a file is already selected in a FileChooserButton and the user hit the Cancel button, another (arbitrary) file is selected.

This but happened in both C and Python GTK+ bindings.

Steps to reproduce:
1. open an application using a FileChooserButton.
2. select a file in the FileChooserButton, select a file and hit the Open button.
3. reopen the FileChooserButton, but just hit the Cancel button.

Actual results:
another file than at step 2 is selected

Expected results:
the same file than at step 2 should be selected; seeing that user have not selected another file.

Does this happen every time?
yes

Other information:
A very small C program example showing the bug:



#include <gtk/gtk.h>

int main (int argc, char **argv)
{
   gtk_init (&argc, &argv);
   
   GtkWidget *w = gtk_window_new (GTK_WINDOW_TOPLEVEL);
   GtkWidget *b = gtk_file_chooser_button_new ("Test", GTK_FILE_CHOOSER_ACTION_OPEN);
   
   g_signal_connect (G_OBJECT (w), "delete_event", gtk_main_quit, NULL);
   
   gtk_container_add (GTK_CONTAINER (w), b);
   
   gtk_widget_show_all (w);
   
   gtk_main ();
}
Comment 1 Luca Bruno 2007-11-27 21:55:19 UTC
Created attachment 99744 [details] [review]
disable selection-changed handling

Hello,
sorry for my poor English.
This is my first patch, i read a bit the code around file chooser.

I would propose this patch. I don't see any reason why the chooser-button should handle dialog selection-changed, so i removed it and everything works very well.
In my mind, it's not useful since the signal is blocked and the combo box won't be updated anyway.
Comment 2 Colomban Wendling 2007-11-27 23:06:31 UTC
Hello,

I think that the "selection-changed" signal is useful, eg if you want to set sensitive a button only if the user have selected a file.

Without the signal, I don't see how to write it, is it possible?


For example, I wrote something like this in a project:


###

class Name:
   
   ...
   
   ifile = None # input filename
   ofile = None # output filename
   
   def __init__ (self, app):
      dialog = gtk.Dialog (...)
      
      ...
      
      ## input file selection
      b_if = gtk.FileChooserButton (_("Select input file"))
      b_if.connect ("selection-changed", self._on_ifile_changed, dialog)
      
      # and the same for the output file (ofile)
      
      ...
   
   def _on_ifile_changed (self, w, dialog):
      self.ifile = w.get_filename ()
      if self.ofile is not None:
         dialog.set_response_sensitive (gtk.RESPONSE_ACCEPT, True)
   
   ...

###


Like you can see, this code set the OK button of the dialog sensitive only if the user have selected both input & output files.
I don't see other easy way to make it working; Is there a way?


Cordially,
Ban

PS:
I can't lay claim for a better English, please excuse me for this probably massacre of the English language...
Comment 3 Luca Bruno 2007-11-29 10:08:17 UTC
There'are two selection-changed, one from gtkchooserbutton and one from the filechooserdialog created by the button. The selection-changed of the dialog was handled by the button, but i didn't see anything working with that.
Instead, the selection-changed emitted by the button is still enabled, this mean your application will work anyway.

Can you try the patch?
Comment 4 Colomban Wendling 2007-11-29 14:49:45 UTC
Hello,

Sorry, I've not tried your patch before. (& I haven't compiled GTK+ before ^^)

Well... It looks very strange. The bug I described seems to be corrected in GTK+ 2.12.2 (I used 2.12.0 before); But with this version, there is the bug you describe, and another one that make the FileChooserDialog duplicate files after some Cancels.

But for the bug you describe, your patch seems to work very well!


PS:
...Hey, this experience make me appears like a stupid guy that doesn't test with the latest version, no? :D It's true...
Comment 5 Luca Bruno 2007-11-29 18:30:03 UTC
Hi,
don't worry if you didn't try, as i said i'm new too here, these are my first gtk compilations from svn ;)
Instead, thanks for this bug report.
Comment 6 Murray Cumming 2008-05-17 10:45:12 UTC
I'm not following all the details, but I wonder if bug #327243 is relevant. Maybe it should be a dependent bug.
Comment 7 Federico Mena Quintero 2013-09-23 20:54:16 UTC

*** This bug has been marked as a duplicate of bug 691040 ***