GtkFileSelection should be used to retrieve file or directory names from the user. It will create a new dialog window containing a directory list, and a file list corresponding to the current working directory. The filesystem can be navigated using the directory list or the drop-down history menu. Alternatively, the TAB key can be used to navigate using filename completion - common in text based editors such as emacs and jed.
</para>
<para>
File selection dialogs are created with a call to gtk_file_selection_new().
</para>
<para>
The default filename can be set using gtk_file_selection_set_filename() and the selected filename retrieved using gtk_file_selection_get_filename().
Simple file operations; create directory, delete file, and rename file, are available from buttons at the top of the dialog. These can be hidden using gtk_file_selection_hide_fileop_buttons() and shown again using gtk_file_selection_show_fileop_buttons().
</para>
<para>
<example>
<title>Getting a filename from the user</title>
<programlisting>
/* The file selection widget and the string to store the chosen filename */
<entry>the dialog box used to display the #GtkFileSelection. It can be customized by adding/removing widgets from it using the standard #GtkDialog functions.</entry>
</row>
<row>
<entry>*dir_list, *file_list;</entry>
<entry>the two #GtkCList widgets corresponding to directories and files.</entry>
</row>
<row>
<entry>*ok_button, *cancel_button;</entry>
<entry>the two main buttons that signals should be connected to in order to perform an action when the user hits either OK or Cancel.</entry>
</row>
<row>
<entry>*history_pulldown;</entry>
<entry>the #GtkOptionMenu used to create the drop-down directory history.</entry>
<entry>the buttons that appear at the top of the file selection dialog. These "operation buttons" can be hidden and redisplayed with gtk_file_selection_hide_fileop_buttons() and gtk_file_selection_show_fileop_buttons() respectively.</entry>
</row>
</tbody></tgroup></informaltable>
</para>
<!-- ##### FUNCTION gtk_file_selection_new ##### -->
<para>
Creates a new file selection dialog box. By default it will contain a #GtkCList of the application's current working directory, and a file listing. Operation buttons that allow the user to create a directory, delete files and rename files, are also present.
</para>
@title: a message that will be placed in the file requestor's titlebar.
@Returns: the new file selection.
<!-- ##### FUNCTION gtk_file_selection_set_filename ##### -->
<para>
Sets a default path for the file requestor. If @filename includes a directory path, then the requestor will open with that path as its current working directory.
</para>
@filesel: a #GtkFileSelection.
@filename: a string to set as the default file name.
<!-- ##### FUNCTION gtk_file_selection_get_filename ##### -->
<para>
Retrieves the currently selected filename from the file selection dialog. If no file is selected then the selected directory path is returned.
</para>
@filesel: a #GtkFileSelection
@Returns: a string containing the selected file's full path.
<!-- ##### FUNCTION gtk_file_selection_complete ##### -->
Will attempt to match @pattern to a valid filenames or subdirectories in the current directory. If a match can be made, the matched filename will appear in the text entry field of the file selection dialog.
If a partial match can be made, the "Files" list will contain those
file names which have been partially matched, and the "Directories"
list those directories which have been partially matched.
@pattern: a string of characters which may or may not match any filenames in the current directory.
<!-- ##### FUNCTION gtk_file_selection_show_fileop_buttons ##### -->
<para>
Shows the file operation buttons, if they have previously been hidden. The rest of the widgets in the dialog will be resized accordingly.
</para>
@filesel: a #GtkFileSelection.
<!-- ##### FUNCTION gtk_file_selection_hide_fileop_buttons ##### -->
<para>
Hides the file operation buttons that normally appear at the top of the dialog. Useful if you wish to create a custom file selector, based on #GtkFileSelection.