GNOME Bugzilla – Bug 325544
GtkFileChooserButton to allow custom "special" path
Last modified: 2013-09-23 20:58:28 UTC
A very useful feature for GtkFileChooserButton would be to allow application developpers to specify "special path", like "current path" (no matter what the path really is). Here is an use case: I need to set up some shell commands to run on a document in gedit. Those would be presented as a menu, and I want to set up the working directory for each command. This directory can be either a predefined directory, or the document path, no matter where the document is stored (/home/sf/foo/ or /etc/X11/xorg.conf). What I have to do is to put a GtkCheckButton beside the GtkFileChooserButton to trigger the "current document directory" special value. This clutter the interface and what it does is not very obvious. What I would prefer is to add a special (non browsable) path "Current document directory" to the GtkFileChooserButton list. (This could be identified by a special icon to be more discoverable)
We need a proposed API and implementation.
Just FYI, it's possible to hack this together today. Emphasis on hack. I've done this for a program I have. (A) Create your own file chooser dialog and pass it to the button upon creation. (B) Create a "/tmp/XXXXXX/Current Document Directory" folder and add it to the button as a shortcut folder. Delete this folder when you're done. (C) When the dialog you own is shown (via Other...) and your special folder was last selected, remove the shortcut folder and set the location to something like $HOME. When the dialog is hidden again, add the shortcut folder back. This avoids exposing the /tmp directory. (D) Just check if the value the user selects is your special folder. Tada! Gross as hell, and you can't control the icon, but it works.
No API proposal was presented, so I'll close this as obsolete.