]> Pileus Git - ~andy/gtk/blob - docs/reference/gtk/tmpl/gtkfilesel.sgml
a426eb3e74bcbf1ff782042f4410c22aef16a4c7
[~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 GtkWidget *file_selector;
38 gchar *selected_filename;
39
40 void store_filename (GtkFileSelection *selector, gpointer user_data) {
41    selected_filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (file_selector));
42 }
43
44 void create_file_selection (void) {
45
46    /* Create the selector */
47    
48    file_selector = gtk_file_selection_new ("Please select a file for editing.");
49    
50    g_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (file_selector)->ok_button),
51                      "clicked",
52                      G_CALLBACK (store_filename),
53                      NULL);
54                            
55    /* Ensure that the dialog box is destroyed when the user clicks a button. */
56    
57    g_signal_connect_swapped (GTK_OBJECT (GTK_FILE_SELECTION (file_selector)->ok_button),
58                              "clicked",
59                              G_CALLBACK (gtk_widget_destroy), 
60                              (gpointer) file_selector); 
61
62    g_signal_connect_swapped (GTK_OBJECT (GTK_FILE_SELECTION (file_selector)->cancel_button),
63                              "clicked",
64                              G_CALLBACK (gtk_widget_destroy),
65                              (gpointer) file_selector); 
66    
67    /* Display that dialog */
68    
69    gtk_widget_show (file_selector);
70 }
71
72 </programlisting>
73 </example>
74 </para>
75
76 <!-- ##### SECTION See_Also ##### -->
77
78 <para>
79 <variablelist>
80 <varlistentry>
81 <term>#GtkDialog</term>
82 <listitem><para>Add your own widgets into the #GtkFileSelection.</para></listitem>
83 </varlistentry>
84 </variablelist>
85 </para>
86
87 <!-- ##### STRUCT GtkFileSelection ##### -->
88 <para>
89 The #GtkFileSelection struct contains the following #GtkWidget fields:
90
91 <informaltable pgwide="1" frame="none" role="struct">
92 <tgroup cols="2"><colspec colwidth="2*"/><colspec colwidth="8*"/>
93 <tbody>
94
95 <row>
96 <entry>*fileop_dialog;</entry>
97 <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>
98 </row>
99
100 <row>
101 <entry>*dir_list, *file_list;</entry>
102 <entry>the two #GtkCList widgets corresponding to directories and files.</entry>
103 </row>
104
105 <row>
106 <entry>*ok_button, *cancel_button;</entry>
107 <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 </row>
109
110 <row>
111 <entry>*history_pulldown;</entry>
112 <entry>the #GtkOptionMenu used to create the drop-down directory history.</entry>
113 </row>
114
115 <row>
116 <entry>*fileop_c_dir, *fileop_del_file, *fileop_ren_file;</entry>
117 <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>
118 </row>
119
120 </tbody></tgroup></informaltable>
121
122 </para>
123
124
125 <!-- ##### FUNCTION gtk_file_selection_new ##### -->
126 <para>
127 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.
128 </para>
129
130 @title: a message that will be placed in the file requestor's titlebar.
131 @Returns: the new file selection.
132
133
134 <!-- ##### FUNCTION gtk_file_selection_set_filename ##### -->
135 <para>
136 </para>
137
138 @filesel: 
139 @filename: 
140
141
142 <!-- ##### FUNCTION gtk_file_selection_get_filename ##### -->
143 <para>
144 </para>
145
146 @filesel: 
147 @Returns: 
148
149
150 <!-- ##### FUNCTION gtk_file_selection_complete ##### -->
151 <para>
152 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.
153 If a partial match can be made, the "Files" list will contain those
154 file names which have been partially matched, and the "Directories"
155 list those directories which have been partially matched.
156 </para>
157
158 @filesel: a #GtkFileSelection.
159 @pattern: a string of characters which may or may not match any filenames in the current directory.
160
161
162 <!-- ##### FUNCTION gtk_file_selection_show_fileop_buttons ##### -->
163 <para>
164 Shows the file operation buttons, if they have previously been hidden. The rest of the widgets in the dialog will be resized accordingly.
165 </para>
166
167 @filesel: a #GtkFileSelection.
168
169
170 <!-- ##### FUNCTION gtk_file_selection_hide_fileop_buttons ##### -->
171 <para>
172 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.
173 </para>
174
175 @filesel: a #GtkFileSelection.
176
177
178 <!-- ##### FUNCTION gtk_file_selection_get_selections ##### -->
179 <para>
180
181 </para>
182
183 @filesel: 
184 @Returns: 
185
186
187 <!-- ##### FUNCTION gtk_file_selection_set_select_multiple ##### -->
188 <para>
189
190 </para>
191
192 @filesel: 
193 @select_multiple: 
194
195
196 <!-- ##### FUNCTION gtk_file_selection_get_select_multiple ##### -->
197 <para>
198
199 </para>
200
201 @filesel: 
202 @Returns: 
203
204
205 <!-- ##### ARG GtkFileSelection:show-fileops ##### -->
206 <para>
207
208 </para>
209
210 <!-- ##### ARG GtkFileSelection:filename ##### -->
211 <para>
212
213 </para>
214
215 <!-- ##### ARG GtkFileSelection:select-multiple ##### -->
216 <para>
217
218 </para>
219