Bug 473143 - zenity --file-selection doesn't handle --filename= option correctly when not using --save
zenity --file-selection doesn't handle --filename= option correctly when not ...
Status: CLOSED RAWHIDE
Product: Fedora
Classification: Fedora
Component: zenity (Show other bugs)
rawhide
All Linux
medium Severity medium
: ---
: ---
Assigned To: Matthias Clasen
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2008-11-26 14:14 EST by Gilles Detillieux
Modified: 2009-01-16 14:57 EST (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2009-01-16 14:57:27 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
patch to fix default file selection in zenity when not using --save (682 bytes, patch)
2008-11-26 14:14 EST, Gilles Detillieux
no flags Details | Diff

  None (edit)
Description Gilles Detillieux 2008-11-26 14:14:12 EST
Created attachment 324780 [details]
patch to fix default file selection in zenity when not using --save

Description of problem:
There is a long-standing problem (at least since Fedora Core 3) in zenity's file selection dialog, when used for opening rather than saving files. If given a file name via the --filename= option, zenity will not select that file name, but instead triggers a failed assertion. There is nothing in zenity's documentation to suggest --filename should only be used with the --save option, and it's reasonable to expect that you should be able to provide a default or current filename for an open dialog, so I'd call this a bug.

Version-Release number of selected component (if applicable):
2.24.0-2.fc10 (all the way back to gnome-utils-2.8.0-5)

How reproducible:
Always.

Steps to Reproduce:
1. zenity --file-selection --filename=.bashrc
  
Actual results:

(zenity:18562): Gtk-CRITICAL **: gtk_file_chooser_default_set_current_name: assertion `impl->action == GTK_FILE_CHOOSER_ACTION_SAVE || impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER' failed

Expected results:
Dialog box should select the named file without complaining.

Additional info:
The fix is actually quite trivial (at least for the case of a single default file name), as the attached patch shows. The GTK documentation for gtk_file_chooser_set_current_name() says: This function is meant for such uses as a suggested name in a "Save As..." dialog. If you want to preselect a particular existing file, you should use gtk_file_chooser_set_filename() instead. So, that's what I did.  Note that if you wanted to allow multiple default filenames to be specified, when using the --multiple option, the single call to gtk_file_chooser_set_filename() would need to be replaced with a loop that separates out all the given file names and calls gtk_file_chooser_select_filename() on each one (note "select" rather than "set", as the set call first unselects everything).
Comment 1 Matthias Clasen 2008-12-14 23:03:15 EST
Thanks for the patch.
Filed upstream here:
http://bugzilla.gnome.org/show_bug.cgi?id=564552
Comment 2 Matthias Clasen 2009-01-16 14:57:27 EST
Committed upstream, will show up in rawhide shortly.

Note You need to log in before you can comment on or make changes to this bug.