]> Pileus Git - ~andy/gtk/blob - docs/reference/gtk/tmpl/gtkfilesel.sgml
Fix the example. (#109563)
[~andy/gtk] / docs / reference / gtk / tmpl / gtkfilesel.sgml
1 <!-- ##### SECTION Title ##### -->
2 GtkFileSelection
3
4 <!-- ##### SECTION Short_Description ##### -->
5 prompt the user for a file or directory name.
6
7 <!-- ##### SECTION Long_Description ##### -->
8 <para>
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.
15 </para>
16 <para>
17 File selection dialogs are created with a call to gtk_file_selection_new().
18 </para>
19 <para>
20 The default filename can be set using gtk_file_selection_set_filename() and the selected filename retrieved using gtk_file_selection_get_filename().
21 </para>
22 <para>
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*.
26 </para>
27 <para>
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().
29 </para>
30 <para>
31 <example>
32 <title>Getting a filename from the user.</title>
33 <programlisting>
34
35 /* The file selection widget and the string to store the chosen filename */
36
37 void store_filename (GtkWidget *file_selector, gpointer user_data) {
38    const gchar *selected_filename;
39
40    selected_filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (file_selector));
41    g_print ("Selected filename: &percnt;s\n", selected_filename);
42 }
43
44 void create_file_selection (void) {
45
46    GtkWidget *file_selector;
47
48    /* Create the selector */
49    
50    file_selector = gtk_file_selection_new ("Please select a file for editing.");
51    
52    g_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (file_selector)->ok_button),
53                      "clicked",
54                      G_CALLBACK (store_filename),
55                      NULL);
56                            
57    /* Ensure that the dialog box is destroyed when the user clicks a button. */
58    
59    g_signal_connect_swapped (GTK_OBJECT (GTK_FILE_SELECTION (file_selector)->ok_button),
60                              "clicked",
61                              G_CALLBACK (gtk_widget_destroy), 
62                              (gpointer) file_selector); 
63
64    g_signal_connect_swapped (GTK_OBJECT (GTK_FILE_SELECTION (file_selector)->cancel_button),
65                              "clicked",
66                              G_CALLBACK (gtk_widget_destroy),
67                              (gpointer) file_selector); 
68    
69    /* Display that dialog */
70    
71    gtk_widget_show (file_selector);
72 }
73
74 </programlisting>
75 </example>
76 </para>
77
78 <!-- ##### SECTION See_Also ##### -->
79
80 <para>
81 <variablelist>
82 <varlistentry>
83 <term>#GtkDialog</term>
84 <listitem><para>Add your own widgets into the #GtkFileSelection.</para></listitem>
85 </varlistentry>
86 </variablelist>
87 </para>
88
89 <!-- ##### STRUCT GtkFileSelection ##### -->
90 <para>
91 The #GtkFileSelection struct contains the following #GtkWidget fields:
92
93 <informaltable pgwide="1" frame="none" role="struct">
94 <tgroup cols="2"><colspec colwidth="2*"/><colspec colwidth="8*"/>
95 <tbody>
96
97 <row>
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>
100 </row>
101
102 <row>
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>
105 </row>
106
107 <row>
108 <entry>*history_pulldown;</entry>
109 <entry>the #GtkOptionMenu used to create the drop-down directory history.</entry>
110 </row>
111
112 <row>
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>
115 </row>
116
117 </tbody></tgroup></informaltable>
118
119 </para>
120
121 @dir_list: 
122 @file_list: 
123 @selection_entry: 
124 @selection_text: 
125 @main_vbox: 
126 @ok_button: 
127 @cancel_button: 
128 @help_button: 
129 @history_pulldown: 
130 @history_menu: 
131 @history_list: 
132 @fileop_dialog: 
133 @fileop_entry: 
134 @fileop_file: 
135 @cmpl_state: 
136 @fileop_c_dir: 
137 @fileop_del_file: 
138 @fileop_ren_file: 
139 @button_area: 
140 @action_area: 
141
142 <!-- ##### FUNCTION gtk_file_selection_new ##### -->
143 <para>
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.
145 </para>
146
147 @title: a message that will be placed in the file requestor's titlebar.
148 @Returns: the new file selection.
149
150
151 <!-- ##### FUNCTION gtk_file_selection_set_filename ##### -->
152 <para>
153 </para>
154
155 @filesel: 
156 @filename: 
157
158
159 <!-- ##### FUNCTION gtk_file_selection_get_filename ##### -->
160 <para>
161 </para>
162
163 @filesel: 
164 @Returns: 
165
166
167 <!-- ##### FUNCTION gtk_file_selection_complete ##### -->
168 <para>
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.
173 </para>
174
175 @filesel: a #GtkFileSelection.
176 @pattern: a string of characters which may or may not match any filenames in the current directory.
177
178
179 <!-- ##### FUNCTION gtk_file_selection_show_fileop_buttons ##### -->
180 <para>
181 Shows the file operation buttons, if they have previously been hidden. The rest of the widgets in the dialog will be resized accordingly.
182 </para>
183
184 @filesel: a #GtkFileSelection.
185
186
187 <!-- ##### FUNCTION gtk_file_selection_hide_fileop_buttons ##### -->
188 <para>
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.
190 </para>
191
192 @filesel: a #GtkFileSelection.
193
194
195 <!-- ##### FUNCTION gtk_file_selection_get_selections ##### -->
196 <para>
197
198 </para>
199
200 @filesel: 
201 @Returns: 
202
203
204 <!-- ##### FUNCTION gtk_file_selection_set_select_multiple ##### -->
205 <para>
206
207 </para>
208
209 @filesel: 
210 @select_multiple: 
211
212
213 <!-- ##### FUNCTION gtk_file_selection_get_select_multiple ##### -->
214 <para>
215
216 </para>
217
218 @filesel: 
219 @Returns: 
220
221
222 <!-- ##### ARG GtkFileSelection:filename ##### -->
223 <para>
224
225 </para>
226
227 <!-- ##### ARG GtkFileSelection:select-multiple ##### -->
228 <para>
229
230 </para>
231
232 <!-- ##### ARG GtkFileSelection:show-fileops ##### -->
233 <para>
234
235 </para>
236