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
29G_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
35typedef 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 */
54typedef 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 */
79typedef 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
86GDK_AVAILABLE_IN_ALL
87GType 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 */
108typedef 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
115GDK_AVAILABLE_IN_ALL
116GQuark gtk_file_chooser_error_quark (void);
117
118/* Configuration
119 */
120__attribute__((weak))
121GDK_AVAILABLE_IN_ALL
122void gtk_file_chooser_set_action (GtkFileChooser *chooser,
123 GtkFileChooserAction action);
124__attribute__((weak))
125GDK_AVAILABLE_IN_ALL
126GtkFileChooserAction gtk_file_chooser_get_action (GtkFileChooser *chooser);
127__attribute__((weak))
128GDK_AVAILABLE_IN_ALL
129void gtk_file_chooser_set_local_only (GtkFileChooser *chooser,
130 gboolean local_only);
131__attribute__((weak))
132GDK_AVAILABLE_IN_ALL
133gboolean gtk_file_chooser_get_local_only (GtkFileChooser *chooser);
134__attribute__((weak))
135GDK_AVAILABLE_IN_ALL
136void gtk_file_chooser_set_select_multiple (GtkFileChooser *chooser,
137 gboolean select_multiple);
138__attribute__((weak))
139GDK_AVAILABLE_IN_ALL
140gboolean gtk_file_chooser_get_select_multiple (GtkFileChooser *chooser);
141__attribute__((weak))
142GDK_AVAILABLE_IN_ALL
143void gtk_file_chooser_set_show_hidden (GtkFileChooser *chooser,
144 gboolean show_hidden);
145__attribute__((weak))
146GDK_AVAILABLE_IN_ALL
147gboolean gtk_file_chooser_get_show_hidden (GtkFileChooser *chooser);
148
149__attribute__((weak))
150GDK_AVAILABLE_IN_ALL
151void gtk_file_chooser_set_do_overwrite_confirmation (GtkFileChooser *chooser,
152 gboolean do_overwrite_confirmation);
153__attribute__((weak))
154GDK_AVAILABLE_IN_ALL
155gboolean gtk_file_chooser_get_do_overwrite_confirmation (GtkFileChooser *chooser);
156
157__attribute__((weak))
158GDK_AVAILABLE_IN_ALL
159void gtk_file_chooser_set_create_folders (GtkFileChooser *chooser,
160 gboolean create_folders);
161__attribute__((weak))
162GDK_AVAILABLE_IN_ALL
163gboolean gtk_file_chooser_get_create_folders (GtkFileChooser *chooser);
164
165/* Suggested name for the Save-type actions
166 */
167__attribute__((weak))
168GDK_AVAILABLE_IN_ALL
169void gtk_file_chooser_set_current_name (GtkFileChooser *chooser,
170 const gchar *name);
171__attribute__((weak))
172GDK_AVAILABLE_IN_3_10
173gchar *gtk_file_chooser_get_current_name (GtkFileChooser *chooser);
174
175/* Filename manipulation
176 */
177__attribute__((weak))
178GDK_AVAILABLE_IN_ALL
179gchar * gtk_file_chooser_get_filename (GtkFileChooser *chooser);
180__attribute__((weak))
181GDK_AVAILABLE_IN_ALL
182gboolean gtk_file_chooser_set_filename (GtkFileChooser *chooser,
183 const char *filename);
184__attribute__((weak))
185GDK_AVAILABLE_IN_ALL
186gboolean gtk_file_chooser_select_filename (GtkFileChooser *chooser,
187 const char *filename);
188__attribute__((weak))
189GDK_AVAILABLE_IN_ALL
190void gtk_file_chooser_unselect_filename (GtkFileChooser *chooser,
191 const char *filename);
192__attribute__((weak))
193GDK_AVAILABLE_IN_ALL
194void gtk_file_chooser_select_all (GtkFileChooser *chooser);
195__attribute__((weak))
196GDK_AVAILABLE_IN_ALL
197void gtk_file_chooser_unselect_all (GtkFileChooser *chooser);
198__attribute__((weak))
199GDK_AVAILABLE_IN_ALL
200GSList * gtk_file_chooser_get_filenames (GtkFileChooser *chooser);
201__attribute__((weak))
202GDK_AVAILABLE_IN_ALL
203gboolean gtk_file_chooser_set_current_folder (GtkFileChooser *chooser,
204 const gchar *filename);
205__attribute__((weak))
206GDK_AVAILABLE_IN_ALL
207gchar * gtk_file_chooser_get_current_folder (GtkFileChooser *chooser);
208
209
210/* URI manipulation
211 */
212__attribute__((weak))
213GDK_AVAILABLE_IN_ALL
214gchar * gtk_file_chooser_get_uri (GtkFileChooser *chooser);
215__attribute__((weak))
216GDK_AVAILABLE_IN_ALL
217gboolean gtk_file_chooser_set_uri (GtkFileChooser *chooser,
218 const char *uri);
219__attribute__((weak))
220GDK_AVAILABLE_IN_ALL
221gboolean gtk_file_chooser_select_uri (GtkFileChooser *chooser,
222 const char *uri);
223__attribute__((weak))
224GDK_AVAILABLE_IN_ALL
225void gtk_file_chooser_unselect_uri (GtkFileChooser *chooser,
226 const char *uri);
227__attribute__((weak))
228GDK_AVAILABLE_IN_ALL
229GSList * gtk_file_chooser_get_uris (GtkFileChooser *chooser);
230__attribute__((weak))
231GDK_AVAILABLE_IN_ALL
232gboolean gtk_file_chooser_set_current_folder_uri (GtkFileChooser *chooser,
233 const gchar *uri);
234__attribute__((weak))
235GDK_AVAILABLE_IN_ALL
236gchar * gtk_file_chooser_get_current_folder_uri (GtkFileChooser *chooser);
237
238/* GFile manipulation */
239__attribute__((weak))
240GDK_AVAILABLE_IN_ALL
241GFile * gtk_file_chooser_get_file (GtkFileChooser *chooser);
242__attribute__((weak))
243GDK_AVAILABLE_IN_ALL
244gboolean gtk_file_chooser_set_file (GtkFileChooser *chooser,
245 GFile *file,
246 GError **error);
247__attribute__((weak))
248GDK_AVAILABLE_IN_ALL
249gboolean gtk_file_chooser_select_file (GtkFileChooser *chooser,
250 GFile *file,
251 GError **error);
252__attribute__((weak))
253GDK_AVAILABLE_IN_ALL
254void gtk_file_chooser_unselect_file (GtkFileChooser *chooser,
255 GFile *file);
256__attribute__((weak))
257GDK_AVAILABLE_IN_ALL
258GSList * gtk_file_chooser_get_files (GtkFileChooser *chooser);
259__attribute__((weak))
260GDK_AVAILABLE_IN_ALL
261gboolean gtk_file_chooser_set_current_folder_file (GtkFileChooser *chooser,
262 GFile *file,
263 GError **error);
264__attribute__((weak))
265GDK_AVAILABLE_IN_ALL
266GFile * gtk_file_chooser_get_current_folder_file (GtkFileChooser *chooser);
267
268/* Preview widget
269 */
270__attribute__((weak))
271GDK_AVAILABLE_IN_ALL
272void gtk_file_chooser_set_preview_widget (GtkFileChooser *chooser,
273 GtkWidget *preview_widget);
274__attribute__((weak))
275GDK_AVAILABLE_IN_ALL
276GtkWidget *gtk_file_chooser_get_preview_widget (GtkFileChooser *chooser);
277__attribute__((weak))
278GDK_AVAILABLE_IN_ALL
279void gtk_file_chooser_set_preview_widget_active (GtkFileChooser *chooser,
280 gboolean active);
281__attribute__((weak))
282GDK_AVAILABLE_IN_ALL
283gboolean gtk_file_chooser_get_preview_widget_active (GtkFileChooser *chooser);
284__attribute__((weak))
285GDK_AVAILABLE_IN_ALL
286void gtk_file_chooser_set_use_preview_label (GtkFileChooser *chooser,
287 gboolean use_label);
288__attribute__((weak))
289GDK_AVAILABLE_IN_ALL
290gboolean gtk_file_chooser_get_use_preview_label (GtkFileChooser *chooser);
291
292__attribute__((weak))
293GDK_AVAILABLE_IN_ALL
294char *gtk_file_chooser_get_preview_filename (GtkFileChooser *chooser);
295__attribute__((weak))
296GDK_AVAILABLE_IN_ALL
297char *gtk_file_chooser_get_preview_uri (GtkFileChooser *chooser);
298__attribute__((weak))
299GDK_AVAILABLE_IN_ALL
300GFile *gtk_file_chooser_get_preview_file (GtkFileChooser *chooser);
301
302/* Extra widget
303 */
304__attribute__((weak))
305GDK_AVAILABLE_IN_ALL
306void gtk_file_chooser_set_extra_widget (GtkFileChooser *chooser,
307 GtkWidget *extra_widget);
308__attribute__((weak))
309GDK_AVAILABLE_IN_ALL
310GtkWidget *gtk_file_chooser_get_extra_widget (GtkFileChooser *chooser);
311
312/* List of user selectable filters
313 */
314__attribute__((weak))
315GDK_AVAILABLE_IN_ALL
316void gtk_file_chooser_add_filter (GtkFileChooser *chooser,
317 GtkFileFilter *filter);
318__attribute__((weak))
319GDK_AVAILABLE_IN_ALL
320void gtk_file_chooser_remove_filter (GtkFileChooser *chooser,
321 GtkFileFilter *filter);
322__attribute__((weak))
323GDK_AVAILABLE_IN_ALL
324GSList *gtk_file_chooser_list_filters (GtkFileChooser *chooser);
325
326/* Current filter
327 */
328__attribute__((weak))
329GDK_AVAILABLE_IN_ALL
330void gtk_file_chooser_set_filter (GtkFileChooser *chooser,
331 GtkFileFilter *filter);
332__attribute__((weak))
333GDK_AVAILABLE_IN_ALL
334GtkFileFilter *gtk_file_chooser_get_filter (GtkFileChooser *chooser);
335
336/* Per-application shortcut folders */
337
338__attribute__((weak))
339GDK_AVAILABLE_IN_ALL
340gboolean gtk_file_chooser_add_shortcut_folder (GtkFileChooser *chooser,
341 const char *folder,
342 GError **error);
343__attribute__((weak))
344GDK_AVAILABLE_IN_ALL
345gboolean gtk_file_chooser_remove_shortcut_folder (GtkFileChooser *chooser,
346 const char *folder,
347 GError **error);
348__attribute__((weak))
349GDK_AVAILABLE_IN_ALL
350GSList *gtk_file_chooser_list_shortcut_folders (GtkFileChooser *chooser);
351
352__attribute__((weak))
353GDK_AVAILABLE_IN_ALL
354gboolean gtk_file_chooser_add_shortcut_folder_uri (GtkFileChooser *chooser,
355 const char *uri,
356 GError **error);
357__attribute__((weak))
358GDK_AVAILABLE_IN_ALL
359gboolean gtk_file_chooser_remove_shortcut_folder_uri (GtkFileChooser *chooser,
360 const char *uri,
361 GError **error);
362__attribute__((weak))
363GDK_AVAILABLE_IN_ALL
364GSList *gtk_file_chooser_list_shortcut_folder_uris (GtkFileChooser *chooser);
365
366__attribute__((weak))
367GDK_AVAILABLE_IN_3_22
368void 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))
374GDK_AVAILABLE_IN_3_22
375void gtk_file_chooser_remove_choice (GtkFileChooser *chooser,
376 const char *id);
377__attribute__((weak))
378GDK_AVAILABLE_IN_3_22
379void gtk_file_chooser_set_choice (GtkFileChooser *chooser,
380 const char *id,
381 const char *option);
382__attribute__((weak))
383GDK_AVAILABLE_IN_3_22
384const char *gtk_file_chooser_get_choice (GtkFileChooser *chooser,
385 const char *id);
386
387G_END_DECLS
388
389#endif /* __GTK_FILE_CHOOSER_H__ */
390