#15133 closed defect (fixed)

The Browse dialog of the wxFilePickerCtrl(wxFLP_SAVE|wxFLP_USE_TEXT_CTRL) shows a blank Name field when a full path has been specified to a file that does not already exist

Reported by: jdagresta Owned by:
Priority: normal Milestone: 2.9.5
Component: wxGTK Version: stable-latest
Keywords: wxGTK wxFilePickerCtrl Cc: jdagresta@…
Blocked By: Blocking:
Patch: yes

Description

Using the wxGTK version of wxFilePickerCtrl(wxFLP_SAVE | wxFLP_USE_TEXT_CTRL), when a full path and filename have been entered in the wxTextCtrl field and you click on the Browse button, the Name field in the "Browse" dialog is blank if the specified file does not already exist.

You can see this with the widgets sample as shown in the following image:
image(filepicker.jpg)?

When you click on the Browse button, this is the result (notice that the Name field is blank):
image(browse_blank.jpg)?

This is the result that should occur:
image(browse_desired.jpg)?

It appeared that the wxGtkFileChooser::SetPath() routine in filectrl.cpp was not calling the correct gtk routines for the SAVE flavor of wxFilePickerCtrl. I determined my proposed fix from looking at the code in wxGtkFileCtrl::Create() (in the same file) for what it did differently with the directory and filename arguments for the SAVE flavor versus the OPEN flavor of dialog.

My proposed changes can be seen in the mypatch.patch attachment.

Jonathan Dagresta

Attachments (4)

filepicker.jpg download (175.0 KB) - added by jdagresta 21 months ago.
browse_blank.jpg download (20.5 KB) - added by jdagresta 21 months ago.
browse_desired.jpg download (13.7 KB) - added by jdagresta 21 months ago.
mypatch.patch download (1.1 KB) - added by jdagresta 20 months ago.
Proposed patch

Download all attachments as: .zip

Change History (9)

Changed 21 months ago by jdagresta

Changed 21 months ago by jdagresta

Changed 21 months ago by jdagresta

comment:1 Changed 21 months ago by jdagresta

(Let me try again using the correct spelling of the Image macro.)

Using the wxGTK version of wxFilePickerCtrl(wxFLP_SAVE | wxFLP_USE_TEXT_CTRL), when a full path and filename have been entered in the wxTextCtrl field and you click on the Browse button, the Name field in the "Browse" dialog is blank if the specified file does not already exist.

You can see this with the widgets sample as shown in the following image:

When you click on the Browse button, this is the result (notice that the Name field is blank):

This is the result that should occur:

It appeared that the wxGtkFileChooser::SetPath() routine in filectrl.cpp was not calling the correct gtk routines for the SAVE flavor of wxFilePickerCtrl. I determined my proposed fix from looking at the code in wxGtkFileCtrl::Create() (in the same file) for what it did differently with the directory and filename arguments for the SAVE flavor versus the OPEN flavor of dialog.

My proposed changes can be seen in the mypatch.patch attachment.

Jonathan Dagresta

Changed 20 months ago by jdagresta

Proposed patch

comment:2 Changed 20 months ago by jdagresta

Just fixed my proposed patch (mypatch.patch) to trunk/src/gtk/filectrl.cpp to 1) eliminate a tab and 2) fix the two return statements to match the change already made with [71685] (#14381).

comment:3 Changed 20 months ago by vadz

  • Milestone set to 2.9.5

The strange thing is that I don't see the problem with GTK+ 2.20 in the widgets sample. Do you use newer (or much older?) GTK+ version?

I don't see any problems with your patch neither so I'll still probably apply it but I'd just like to understand what's going on here. I must admit I'm rather confused by the interaction between gtk_file_chooser_set_current_name() and gtk_file_chooser_set_filename()...

comment:4 Changed 20 months ago by jdagresta

We have GTK+ 2.10 on our Red Hat Linux 5 (RH5) systems, GTK+ 2.18 on our AIX 5.3 systems, and it looks like only GTK+ 2.4 on our Solaris 10 systems. So it appears that the problem still happened with version 2.18 of GTK+.

As far as the RH5 systems, GTK+ 2.10 is the latest version of that package available (via the system update utility 'yum') and that's all that would be available to our customers using that OS as well.

It looks like GTK+ 2.20 is available as an update for AIX 5.3 (although it's not that easy to get our customers to update their OS once they are up and running in production) and I've not yet been able to tell if there's any GTK+ update available for Solaris 10.

When our customers ran into this problem in our application (on all of the RH5, AIX 5.3, and Solaris 10 platforms) and I looked at the wxWidgets code, I was thinking it was probably actually a GTK+ bug in gtk_file_chooser_set_filename() (in setting the Name field for the SAVE case when the file does not exist). But then I saw in src/gtk/filectrl.cpp in wxGtkFileCtrl::Create() that it was doing something different for the wxFLP_SAVE case than for wxFLP_OPEN (which is where I got my "fix"). That could very well have been done in the past due to the GTK+ bug.

So if you're seeing that this problem is fixed in GTK+ 2.20, then it's up to you whether or not you want to apply the patch. I can just make the patch changes in our current version of wxWidgets and at some point in the future these patch changes should no longer be necessary (although it may take some time for GTK+ 2.20 to be available as an update on the RH5 and Solaris platforms).

comment:5 Changed 20 months ago by VZ

  • Resolution set to fixed
  • Status changed from new to closed

(In [73932]) Don't use gtk_file_chooser_set_filename() for save file dialogs.

This seems to be broken in old GTK+ versions, so use
gtk_file_chooser_set_current_name() and gtk_file_chooser_set_current_folder()
for save file dialogs which seem to work in all versions.

Closes #15133.

Note: See TracTickets for help on using tickets.