Description
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, the drop-down history menu, or the TAB key can be used to navigate using filename completion common in text based editors such as emacs and jed.
File selection dialogs are created with a call to gtk_file_selection_new().
The default filename can be set using gtk_file_selection_set_filename() and the selected filename retrieved using gtk_file_selection_get_filename().
Use gtk_file_selection_complete() to display files that match a given pattern. This can be used for example, to show only *.txt files, or only files beginning with gtk*.
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().
Details
struct GtkFileSelection
dir_list and file_list are GtkWidget pointers to the two GtkCList widgets for directories and files.
ok_button and cancel_button are the two main buttons that signals should be connected to in order to perform an action when the user hits either OK or Cancel.
history_pulldown is a GtkWidget pointer to the GtkOptionMenu used to create the drop-down directory history.
fileop_c_dir, fileop_del_file and fileop_ren_file are GtkWidget pointers to 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.
gtk_file_selection_new ()
Creates a new file selection dialog box. By default it will contain a GtkCList of the current working directory, and a file listing. Operation buttons allowing the user to create a directory, delete files, and rename files are also present.
gtk_file_selection_set_filename ()
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.
gtk_file_selection_get_filename ()
Retrieves the currently selected filename from the file selection dialog. If no file is selected then the selected directory path is returned.
gtk_file_selection_complete ()
Will attempt to match pattern to a valid filename 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.
gtk_file_selection_show_fileop_buttons ()
Shows the file operation buttons, if they have previously been hidden. The rest of the widgets in the dialog will be resized accordingly.
gtk_file_selection_hide_fileop_buttons ()
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.