1 | /* GTK - The GIMP Toolkit |
2 | * gtkfilechooser.h: Abstract interface for file selector GUIs |
3 | * Copyright (C) 2003, Red Hat, Inc. |
4 | * |
5 | * This library is free software; you can redistribute it and/or |
6 | * modify it under the terms of the GNU Lesser General Public |
7 | * License as published by the Free Software Foundation; either |
8 | * version 2 of the License, or (at your option) any later version. |
9 | * |
10 | * This library is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | * Lesser General Public License for more details. |
14 | * |
15 | * You should have received a copy of the GNU Lesser General Public |
16 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. |
17 | */ |
18 | |
19 | #ifndef __GTK_FILE_CHOOSER_H__ |
20 | #define __GTK_FILE_CHOOSER_H__ |
21 | |
22 | #if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION) |
23 | #error "Only <gtk/gtk.h> can be included directly." |
24 | #endif |
25 | |
26 | #include <gtk/gtkfilefilter.h> |
27 | #include <gtk/gtkwidget.h> |
28 | |
29 | G_BEGIN_DECLS |
30 | |
31 | #define GTK_TYPE_FILE_CHOOSER (gtk_file_chooser_get_type ()) |
32 | #define GTK_FILE_CHOOSER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_FILE_CHOOSER, GtkFileChooser)) |
33 | #define GTK_IS_FILE_CHOOSER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_FILE_CHOOSER)) |
34 | |
35 | typedef struct _GtkFileChooser GtkFileChooser; |
36 | |
37 | /** |
38 | * GtkFileChooserAction: |
39 | * @GTK_FILE_CHOOSER_ACTION_OPEN: Indicates open mode. The file chooser |
40 | * will only let the user pick an existing file. |
41 | * @GTK_FILE_CHOOSER_ACTION_SAVE: Indicates save mode. The file chooser |
42 | * will let the user pick an existing file, or type in a new |
43 | * filename. |
44 | * @GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER: Indicates an Open mode for |
45 | * selecting folders. The file chooser will let the user pick an |
46 | * existing folder. |
47 | * @GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER: Indicates a mode for creating a |
48 | * new folder. The file chooser will let the user name an existing or |
49 | * new folder. |
50 | * |
51 | * Describes whether a #GtkFileChooser is being used to open existing files |
52 | * or to save to a possibly new file. |
53 | */ |
54 | typedef enum |
55 | { |
56 | GTK_FILE_CHOOSER_ACTION_OPEN, |
57 | GTK_FILE_CHOOSER_ACTION_SAVE, |
58 | GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, |
59 | GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER |
60 | } GtkFileChooserAction; |
61 | |
62 | /** |
63 | * GtkFileChooserConfirmation: |
64 | * @GTK_FILE_CHOOSER_CONFIRMATION_CONFIRM: The file chooser will present |
65 | * its stock dialog to confirm about overwriting an existing file. |
66 | * @GTK_FILE_CHOOSER_CONFIRMATION_ACCEPT_FILENAME: The file chooser will |
67 | * terminate and accept the user’s choice of a file name. |
68 | * @GTK_FILE_CHOOSER_CONFIRMATION_SELECT_AGAIN: The file chooser will |
69 | * continue running, so as to let the user select another file name. |
70 | * |
71 | * Used as a return value of handlers for the |
72 | * #GtkFileChooser::confirm-overwrite signal of a #GtkFileChooser. This |
73 | * value determines whether the file chooser will present the stock |
74 | * confirmation dialog, accept the user’s choice of a filename, or |
75 | * let the user choose another filename. |
76 | * |
77 | * Since: 2.8 |
78 | */ |
79 | typedef enum |
80 | { |
81 | GTK_FILE_CHOOSER_CONFIRMATION_CONFIRM, |
82 | GTK_FILE_CHOOSER_CONFIRMATION_ACCEPT_FILENAME, |
83 | GTK_FILE_CHOOSER_CONFIRMATION_SELECT_AGAIN |
84 | } GtkFileChooserConfirmation; |
85 | |
86 | GDK_AVAILABLE_IN_ALL |
87 | GType gtk_file_chooser_get_type (void) G_GNUC_CONST; |
88 | |
89 | /* GError enumeration for GtkFileChooser */ |
90 | /** |
91 | * GTK_FILE_CHOOSER_ERROR: |
92 | * |
93 | * Used to get the #GError quark for #GtkFileChooser errors. |
94 | */ |
95 | #define GTK_FILE_CHOOSER_ERROR (gtk_file_chooser_error_quark ()) |
96 | |
97 | /** |
98 | * GtkFileChooserError: |
99 | * @GTK_FILE_CHOOSER_ERROR_NONEXISTENT: Indicates that a file does not exist. |
100 | * @GTK_FILE_CHOOSER_ERROR_BAD_FILENAME: Indicates a malformed filename. |
101 | * @GTK_FILE_CHOOSER_ERROR_ALREADY_EXISTS: Indicates a duplicate path (e.g. when |
102 | * adding a bookmark). |
103 | * @GTK_FILE_CHOOSER_ERROR_INCOMPLETE_HOSTNAME: Indicates an incomplete hostname (e.g. "http://foo" without a slash after that). |
104 | * |
105 | * These identify the various errors that can occur while calling |
106 | * #GtkFileChooser functions. |
107 | */ |
108 | typedef enum { |
109 | GTK_FILE_CHOOSER_ERROR_NONEXISTENT, |
110 | GTK_FILE_CHOOSER_ERROR_BAD_FILENAME, |
111 | GTK_FILE_CHOOSER_ERROR_ALREADY_EXISTS, |
112 | GTK_FILE_CHOOSER_ERROR_INCOMPLETE_HOSTNAME |
113 | } GtkFileChooserError; |
114 | |
115 | GDK_AVAILABLE_IN_ALL |
116 | GQuark gtk_file_chooser_error_quark (void); |
117 | |
118 | /* Configuration |
119 | */ |
120 | __attribute__((weak)) |
121 | GDK_AVAILABLE_IN_ALL |
122 | void gtk_file_chooser_set_action (GtkFileChooser *chooser, |
123 | GtkFileChooserAction action); |
124 | __attribute__((weak)) |
125 | GDK_AVAILABLE_IN_ALL |
126 | GtkFileChooserAction gtk_file_chooser_get_action (GtkFileChooser *chooser); |
127 | __attribute__((weak)) |
128 | GDK_AVAILABLE_IN_ALL |
129 | void gtk_file_chooser_set_local_only (GtkFileChooser *chooser, |
130 | gboolean local_only); |
131 | __attribute__((weak)) |
132 | GDK_AVAILABLE_IN_ALL |
133 | gboolean gtk_file_chooser_get_local_only (GtkFileChooser *chooser); |
134 | __attribute__((weak)) |
135 | GDK_AVAILABLE_IN_ALL |
136 | void gtk_file_chooser_set_select_multiple (GtkFileChooser *chooser, |
137 | gboolean select_multiple); |
138 | __attribute__((weak)) |
139 | GDK_AVAILABLE_IN_ALL |
140 | gboolean gtk_file_chooser_get_select_multiple (GtkFileChooser *chooser); |
141 | __attribute__((weak)) |
142 | GDK_AVAILABLE_IN_ALL |
143 | void gtk_file_chooser_set_show_hidden (GtkFileChooser *chooser, |
144 | gboolean show_hidden); |
145 | __attribute__((weak)) |
146 | GDK_AVAILABLE_IN_ALL |
147 | gboolean gtk_file_chooser_get_show_hidden (GtkFileChooser *chooser); |
148 | |
149 | __attribute__((weak)) |
150 | GDK_AVAILABLE_IN_ALL |
151 | void gtk_file_chooser_set_do_overwrite_confirmation (GtkFileChooser *chooser, |
152 | gboolean do_overwrite_confirmation); |
153 | __attribute__((weak)) |
154 | GDK_AVAILABLE_IN_ALL |
155 | gboolean gtk_file_chooser_get_do_overwrite_confirmation (GtkFileChooser *chooser); |
156 | |
157 | __attribute__((weak)) |
158 | GDK_AVAILABLE_IN_ALL |
159 | void gtk_file_chooser_set_create_folders (GtkFileChooser *chooser, |
160 | gboolean create_folders); |
161 | __attribute__((weak)) |
162 | GDK_AVAILABLE_IN_ALL |
163 | gboolean gtk_file_chooser_get_create_folders (GtkFileChooser *chooser); |
164 | |
165 | /* Suggested name for the Save-type actions |
166 | */ |
167 | __attribute__((weak)) |
168 | GDK_AVAILABLE_IN_ALL |
169 | void gtk_file_chooser_set_current_name (GtkFileChooser *chooser, |
170 | const gchar *name); |
171 | __attribute__((weak)) |
172 | GDK_AVAILABLE_IN_3_10 |
173 | gchar *gtk_file_chooser_get_current_name (GtkFileChooser *chooser); |
174 | |
175 | /* Filename manipulation |
176 | */ |
177 | __attribute__((weak)) |
178 | GDK_AVAILABLE_IN_ALL |
179 | gchar * gtk_file_chooser_get_filename (GtkFileChooser *chooser); |
180 | __attribute__((weak)) |
181 | GDK_AVAILABLE_IN_ALL |
182 | gboolean gtk_file_chooser_set_filename (GtkFileChooser *chooser, |
183 | const char *filename); |
184 | __attribute__((weak)) |
185 | GDK_AVAILABLE_IN_ALL |
186 | gboolean gtk_file_chooser_select_filename (GtkFileChooser *chooser, |
187 | const char *filename); |
188 | __attribute__((weak)) |
189 | GDK_AVAILABLE_IN_ALL |
190 | void gtk_file_chooser_unselect_filename (GtkFileChooser *chooser, |
191 | const char *filename); |
192 | __attribute__((weak)) |
193 | GDK_AVAILABLE_IN_ALL |
194 | void gtk_file_chooser_select_all (GtkFileChooser *chooser); |
195 | __attribute__((weak)) |
196 | GDK_AVAILABLE_IN_ALL |
197 | void gtk_file_chooser_unselect_all (GtkFileChooser *chooser); |
198 | __attribute__((weak)) |
199 | GDK_AVAILABLE_IN_ALL |
200 | GSList * gtk_file_chooser_get_filenames (GtkFileChooser *chooser); |
201 | __attribute__((weak)) |
202 | GDK_AVAILABLE_IN_ALL |
203 | gboolean gtk_file_chooser_set_current_folder (GtkFileChooser *chooser, |
204 | const gchar *filename); |
205 | __attribute__((weak)) |
206 | GDK_AVAILABLE_IN_ALL |
207 | gchar * gtk_file_chooser_get_current_folder (GtkFileChooser *chooser); |
208 | |
209 | |
210 | /* URI manipulation |
211 | */ |
212 | __attribute__((weak)) |
213 | GDK_AVAILABLE_IN_ALL |
214 | gchar * gtk_file_chooser_get_uri (GtkFileChooser *chooser); |
215 | __attribute__((weak)) |
216 | GDK_AVAILABLE_IN_ALL |
217 | gboolean gtk_file_chooser_set_uri (GtkFileChooser *chooser, |
218 | const char *uri); |
219 | __attribute__((weak)) |
220 | GDK_AVAILABLE_IN_ALL |
221 | gboolean gtk_file_chooser_select_uri (GtkFileChooser *chooser, |
222 | const char *uri); |
223 | __attribute__((weak)) |
224 | GDK_AVAILABLE_IN_ALL |
225 | void gtk_file_chooser_unselect_uri (GtkFileChooser *chooser, |
226 | const char *uri); |
227 | __attribute__((weak)) |
228 | GDK_AVAILABLE_IN_ALL |
229 | GSList * gtk_file_chooser_get_uris (GtkFileChooser *chooser); |
230 | __attribute__((weak)) |
231 | GDK_AVAILABLE_IN_ALL |
232 | gboolean gtk_file_chooser_set_current_folder_uri (GtkFileChooser *chooser, |
233 | const gchar *uri); |
234 | __attribute__((weak)) |
235 | GDK_AVAILABLE_IN_ALL |
236 | gchar * gtk_file_chooser_get_current_folder_uri (GtkFileChooser *chooser); |
237 | |
238 | /* GFile manipulation */ |
239 | __attribute__((weak)) |
240 | GDK_AVAILABLE_IN_ALL |
241 | GFile * gtk_file_chooser_get_file (GtkFileChooser *chooser); |
242 | __attribute__((weak)) |
243 | GDK_AVAILABLE_IN_ALL |
244 | gboolean gtk_file_chooser_set_file (GtkFileChooser *chooser, |
245 | GFile *file, |
246 | GError **error); |
247 | __attribute__((weak)) |
248 | GDK_AVAILABLE_IN_ALL |
249 | gboolean gtk_file_chooser_select_file (GtkFileChooser *chooser, |
250 | GFile *file, |
251 | GError **error); |
252 | __attribute__((weak)) |
253 | GDK_AVAILABLE_IN_ALL |
254 | void gtk_file_chooser_unselect_file (GtkFileChooser *chooser, |
255 | GFile *file); |
256 | __attribute__((weak)) |
257 | GDK_AVAILABLE_IN_ALL |
258 | GSList * gtk_file_chooser_get_files (GtkFileChooser *chooser); |
259 | __attribute__((weak)) |
260 | GDK_AVAILABLE_IN_ALL |
261 | gboolean gtk_file_chooser_set_current_folder_file (GtkFileChooser *chooser, |
262 | GFile *file, |
263 | GError **error); |
264 | __attribute__((weak)) |
265 | GDK_AVAILABLE_IN_ALL |
266 | GFile * gtk_file_chooser_get_current_folder_file (GtkFileChooser *chooser); |
267 | |
268 | /* Preview widget |
269 | */ |
270 | __attribute__((weak)) |
271 | GDK_AVAILABLE_IN_ALL |
272 | void gtk_file_chooser_set_preview_widget (GtkFileChooser *chooser, |
273 | GtkWidget *preview_widget); |
274 | __attribute__((weak)) |
275 | GDK_AVAILABLE_IN_ALL |
276 | GtkWidget *gtk_file_chooser_get_preview_widget (GtkFileChooser *chooser); |
277 | __attribute__((weak)) |
278 | GDK_AVAILABLE_IN_ALL |
279 | void gtk_file_chooser_set_preview_widget_active (GtkFileChooser *chooser, |
280 | gboolean active); |
281 | __attribute__((weak)) |
282 | GDK_AVAILABLE_IN_ALL |
283 | gboolean gtk_file_chooser_get_preview_widget_active (GtkFileChooser *chooser); |
284 | __attribute__((weak)) |
285 | GDK_AVAILABLE_IN_ALL |
286 | void gtk_file_chooser_set_use_preview_label (GtkFileChooser *chooser, |
287 | gboolean use_label); |
288 | __attribute__((weak)) |
289 | GDK_AVAILABLE_IN_ALL |
290 | gboolean gtk_file_chooser_get_use_preview_label (GtkFileChooser *chooser); |
291 | |
292 | __attribute__((weak)) |
293 | GDK_AVAILABLE_IN_ALL |
294 | char *gtk_file_chooser_get_preview_filename (GtkFileChooser *chooser); |
295 | __attribute__((weak)) |
296 | GDK_AVAILABLE_IN_ALL |
297 | char *gtk_file_chooser_get_preview_uri (GtkFileChooser *chooser); |
298 | __attribute__((weak)) |
299 | GDK_AVAILABLE_IN_ALL |
300 | GFile *gtk_file_chooser_get_preview_file (GtkFileChooser *chooser); |
301 | |
302 | /* Extra widget |
303 | */ |
304 | __attribute__((weak)) |
305 | GDK_AVAILABLE_IN_ALL |
306 | void (GtkFileChooser *chooser, |
307 | GtkWidget *); |
308 | __attribute__((weak)) |
309 | GDK_AVAILABLE_IN_ALL |
310 | GtkWidget * (GtkFileChooser *chooser); |
311 | |
312 | /* List of user selectable filters |
313 | */ |
314 | __attribute__((weak)) |
315 | GDK_AVAILABLE_IN_ALL |
316 | void gtk_file_chooser_add_filter (GtkFileChooser *chooser, |
317 | GtkFileFilter *filter); |
318 | __attribute__((weak)) |
319 | GDK_AVAILABLE_IN_ALL |
320 | void gtk_file_chooser_remove_filter (GtkFileChooser *chooser, |
321 | GtkFileFilter *filter); |
322 | __attribute__((weak)) |
323 | GDK_AVAILABLE_IN_ALL |
324 | GSList *gtk_file_chooser_list_filters (GtkFileChooser *chooser); |
325 | |
326 | /* Current filter |
327 | */ |
328 | __attribute__((weak)) |
329 | GDK_AVAILABLE_IN_ALL |
330 | void gtk_file_chooser_set_filter (GtkFileChooser *chooser, |
331 | GtkFileFilter *filter); |
332 | __attribute__((weak)) |
333 | GDK_AVAILABLE_IN_ALL |
334 | GtkFileFilter *gtk_file_chooser_get_filter (GtkFileChooser *chooser); |
335 | |
336 | /* Per-application shortcut folders */ |
337 | |
338 | __attribute__((weak)) |
339 | GDK_AVAILABLE_IN_ALL |
340 | gboolean gtk_file_chooser_add_shortcut_folder (GtkFileChooser *chooser, |
341 | const char *folder, |
342 | GError **error); |
343 | __attribute__((weak)) |
344 | GDK_AVAILABLE_IN_ALL |
345 | gboolean gtk_file_chooser_remove_shortcut_folder (GtkFileChooser *chooser, |
346 | const char *folder, |
347 | GError **error); |
348 | __attribute__((weak)) |
349 | GDK_AVAILABLE_IN_ALL |
350 | GSList *gtk_file_chooser_list_shortcut_folders (GtkFileChooser *chooser); |
351 | |
352 | __attribute__((weak)) |
353 | GDK_AVAILABLE_IN_ALL |
354 | gboolean gtk_file_chooser_add_shortcut_folder_uri (GtkFileChooser *chooser, |
355 | const char *uri, |
356 | GError **error); |
357 | __attribute__((weak)) |
358 | GDK_AVAILABLE_IN_ALL |
359 | gboolean gtk_file_chooser_remove_shortcut_folder_uri (GtkFileChooser *chooser, |
360 | const char *uri, |
361 | GError **error); |
362 | __attribute__((weak)) |
363 | GDK_AVAILABLE_IN_ALL |
364 | GSList *gtk_file_chooser_list_shortcut_folder_uris (GtkFileChooser *chooser); |
365 | |
366 | __attribute__((weak)) |
367 | GDK_AVAILABLE_IN_3_22 |
368 | void gtk_file_chooser_add_choice (GtkFileChooser *chooser, |
369 | const char *id, |
370 | const char *label, |
371 | const char **options, |
372 | const char **option_labels); |
373 | __attribute__((weak)) |
374 | GDK_AVAILABLE_IN_3_22 |
375 | void gtk_file_chooser_remove_choice (GtkFileChooser *chooser, |
376 | const char *id); |
377 | __attribute__((weak)) |
378 | GDK_AVAILABLE_IN_3_22 |
379 | void gtk_file_chooser_set_choice (GtkFileChooser *chooser, |
380 | const char *id, |
381 | const char *option); |
382 | __attribute__((weak)) |
383 | GDK_AVAILABLE_IN_3_22 |
384 | const char *gtk_file_chooser_get_choice (GtkFileChooser *chooser, |
385 | const char *id); |
386 | |
387 | G_END_DECLS |
388 | |
389 | #endif /* __GTK_FILE_CHOOSER_H__ */ |
390 | |