Bug 473143 - zenity --file-selection doesn't handle --filename= option correctly when not using --save
Summary: zenity --file-selection doesn't handle --filename= option correctly when not ...
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: zenity
Version: rawhide
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Matthias Clasen
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2008-11-26 19:14 UTC by Gilles Detillieux
Modified: 2009-01-16 19:57 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2009-01-16 19:57:27 UTC
Type: ---
Embargoed:


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

Description Gilles Detillieux 2008-11-26 19:14:12 UTC
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-15 04:03:15 UTC
Thanks for the patch.
Filed upstream here:
http://bugzilla.gnome.org/show_bug.cgi?id=564552

Comment 2 Matthias Clasen 2009-01-16 19:57:27 UTC
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.