1 <!-- ##### SECTION Title ##### -->
4 <!-- ##### SECTION Short_Description ##### -->
5 prompt the user for a file or directory name.
7 <!-- ##### SECTION Long_Description ##### -->
9 #GtkFileSelection should be used to retrieve file or directory names from
10 the user. It will create a new dialog window containing a directory list,
11 and a file list corresponding to the current working directory. The filesystem
12 can be navigated using the directory list or the drop-down history menu.
13 Alternatively, the TAB key can be used to navigate using filename
14 completion - common in text based editors such as emacs and jed.
17 File selection dialogs are created with a call to gtk_file_selection_new().
20 The default filename can be set using gtk_file_selection_set_filename() and the selected filename retrieved using gtk_file_selection_get_filename().
23 Use gtk_file_selection_complete() to display files and directories
24 that match a given pattern. This can be used for example, to show only
25 *.txt files, or only files beginning with gtk*.
28 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().
32 <title>Getting a filename from the user.</title>
35 /* The file selection widget and the string to store the chosen filename */
37 void store_filename (GtkWidget *file_selector, gpointer user_data) {
38 const gchar *selected_filename;
40 selected_filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (file_selector));
41 g_print ("Selected filename: %s\n", selected_filename);
44 void create_file_selection (void) {
46 GtkWidget *file_selector;
48 /* Create the selector */
50 file_selector = gtk_file_selection_new ("Please select a file for editing.");
52 g_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (file_selector)->ok_button),
54 G_CALLBACK (store_filename),
57 /* Ensure that the dialog box is destroyed when the user clicks a button. */
59 g_signal_connect_swapped (GTK_OBJECT (GTK_FILE_SELECTION (file_selector)->ok_button),
61 G_CALLBACK (gtk_widget_destroy),
62 (gpointer) file_selector);
64 g_signal_connect_swapped (GTK_OBJECT (GTK_FILE_SELECTION (file_selector)->cancel_button),
66 G_CALLBACK (gtk_widget_destroy),
67 (gpointer) file_selector);
69 /* Display that dialog */
71 gtk_widget_show (file_selector);
78 <!-- ##### SECTION See_Also ##### -->
83 <term>#GtkDialog</term>
84 <listitem><para>Add your own widgets into the #GtkFileSelection.</para></listitem>
89 <!-- ##### STRUCT GtkFileSelection ##### -->
91 The #GtkFileSelection struct contains the following #GtkWidget fields:
93 <informaltable pgwide="1" frame="none" role="struct">
94 <tgroup cols="2"><colspec colwidth="2*"/><colspec colwidth="8*"/>
98 <entry>*fileop_dialog;</entry>
99 <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>
103 <entry>*ok_button, *cancel_button;</entry>
104 <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>
108 <entry>*history_pulldown;</entry>
109 <entry>the #GtkOptionMenu used to create the drop-down directory history.</entry>
113 <entry>*fileop_c_dir, *fileop_del_file, *fileop_ren_file;</entry>
114 <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>
117 </tbody></tgroup></informaltable>
142 <!-- ##### FUNCTION gtk_file_selection_new ##### -->
144 Creates a new file selection dialog box. By default it will contain a #GtkTreeView 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.
147 @title: a message that will be placed in the file requestor's titlebar.
148 @Returns: the new file selection.
151 <!-- ##### FUNCTION gtk_file_selection_set_filename ##### -->
159 <!-- ##### FUNCTION gtk_file_selection_get_filename ##### -->
167 <!-- ##### FUNCTION gtk_file_selection_complete ##### -->
169 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.
170 If a partial match can be made, the "Files" list will contain those
171 file names which have been partially matched, and the "Folders"
172 list those directories which have been partially matched.
175 @filesel: a #GtkFileSelection.
176 @pattern: a string of characters which may or may not match any filenames in the current directory.
179 <!-- ##### FUNCTION gtk_file_selection_show_fileop_buttons ##### -->
181 Shows the file operation buttons, if they have previously been hidden. The rest of the widgets in the dialog will be resized accordingly.
184 @filesel: a #GtkFileSelection.
187 <!-- ##### FUNCTION gtk_file_selection_hide_fileop_buttons ##### -->
189 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.
192 @filesel: a #GtkFileSelection.
195 <!-- ##### FUNCTION gtk_file_selection_get_selections ##### -->
204 <!-- ##### FUNCTION gtk_file_selection_set_select_multiple ##### -->
213 <!-- ##### FUNCTION gtk_file_selection_get_select_multiple ##### -->
222 <!-- ##### ARG GtkFileSelection:filename ##### -->
227 <!-- ##### ARG GtkFileSelection:select-multiple ##### -->
232 <!-- ##### ARG GtkFileSelection:show-fileops ##### -->