<< Back to man.ChinaUnix.net

<< Back to man.ChinaUnix.net

Selection Modes

GtkFileChooser can be used in two modes, to select a single file at a time or to select a set of more than one file. To set this, use gtk_file_chooser_set_select_multiple(). In single-selection mode, you can use gtk_file_chooser_get_filename() to get a file name from the local file system or gtk_file_chooser_get_uri() to get a full-formed URI. In multiple-selection mode, you can use gtk_file_chooser_get_filenames() to get a GSList of filename strings, or gtk_file_chooser_get_uris() to get a list of URI strings.

Also, you can configure GtkFileChooser to select files or folders. Consider a backup program that needs to let the user select a folder that will be backed up along with its subfolders. To configure whether GtkFileChooser is used to select files or folders, use gtk_file_chooser_set_action(). In addition, this lets you configure whether the file chooser will be used to select existing files or folders (e.g. for "File/Open"), or to type in new filenames (for "File/Save As...").