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 | GDK_AVAILABLE_IN_ALL |
121 | void gtk_file_chooser_set_action (GtkFileChooser *chooser, |
122 | GtkFileChooserAction action); |
123 | GDK_AVAILABLE_IN_ALL |
124 | GtkFileChooserAction gtk_file_chooser_get_action (GtkFileChooser *chooser); |
125 | GDK_AVAILABLE_IN_ALL |
126 | void gtk_file_chooser_set_local_only (GtkFileChooser *chooser, |
127 | gboolean local_only); |
128 | GDK_AVAILABLE_IN_ALL |
129 | gboolean gtk_file_chooser_get_local_only (GtkFileChooser *chooser); |
130 | GDK_AVAILABLE_IN_ALL |
131 | void gtk_file_chooser_set_select_multiple (GtkFileChooser *chooser, |
132 | gboolean select_multiple); |
133 | GDK_AVAILABLE_IN_ALL |
134 | gboolean gtk_file_chooser_get_select_multiple (GtkFileChooser *chooser); |
135 | GDK_AVAILABLE_IN_ALL |
136 | void gtk_file_chooser_set_show_hidden (GtkFileChooser *chooser, |
137 | gboolean show_hidden); |
138 | GDK_AVAILABLE_IN_ALL |
139 | gboolean gtk_file_chooser_get_show_hidden (GtkFileChooser *chooser); |
140 | |
141 | GDK_AVAILABLE_IN_ALL |
142 | void gtk_file_chooser_set_do_overwrite_confirmation (GtkFileChooser *chooser, |
143 | gboolean do_overwrite_confirmation); |
144 | GDK_AVAILABLE_IN_ALL |
145 | gboolean gtk_file_chooser_get_do_overwrite_confirmation (GtkFileChooser *chooser); |
146 | |
147 | GDK_AVAILABLE_IN_ALL |
148 | void gtk_file_chooser_set_create_folders (GtkFileChooser *chooser, |
149 | gboolean create_folders); |
150 | GDK_AVAILABLE_IN_ALL |
151 | gboolean gtk_file_chooser_get_create_folders (GtkFileChooser *chooser); |
152 | |
153 | /* Suggested name for the Save-type actions |
154 | */ |
155 | GDK_AVAILABLE_IN_ALL |
156 | void gtk_file_chooser_set_current_name (GtkFileChooser *chooser, |
157 | const gchar *name); |
158 | GDK_AVAILABLE_IN_3_10 |
159 | gchar *gtk_file_chooser_get_current_name (GtkFileChooser *chooser); |
160 | |
161 | /* Filename manipulation |
162 | */ |
163 | GDK_AVAILABLE_IN_ALL |
164 | gchar * gtk_file_chooser_get_filename (GtkFileChooser *chooser); |
165 | GDK_AVAILABLE_IN_ALL |
166 | gboolean gtk_file_chooser_set_filename (GtkFileChooser *chooser, |
167 | const char *filename); |
168 | GDK_AVAILABLE_IN_ALL |
169 | gboolean gtk_file_chooser_select_filename (GtkFileChooser *chooser, |
170 | const char *filename); |
171 | GDK_AVAILABLE_IN_ALL |
172 | void gtk_file_chooser_unselect_filename (GtkFileChooser *chooser, |
173 | const char *filename); |
174 | GDK_AVAILABLE_IN_ALL |
175 | void gtk_file_chooser_select_all (GtkFileChooser *chooser); |
176 | GDK_AVAILABLE_IN_ALL |
177 | void gtk_file_chooser_unselect_all (GtkFileChooser *chooser); |
178 | GDK_AVAILABLE_IN_ALL |
179 | GSList * gtk_file_chooser_get_filenames (GtkFileChooser *chooser); |
180 | GDK_AVAILABLE_IN_ALL |
181 | gboolean gtk_file_chooser_set_current_folder (GtkFileChooser *chooser, |
182 | const gchar *filename); |
183 | GDK_AVAILABLE_IN_ALL |
184 | gchar * gtk_file_chooser_get_current_folder (GtkFileChooser *chooser); |
185 | |
186 | |
187 | /* URI manipulation |
188 | */ |
189 | GDK_AVAILABLE_IN_ALL |
190 | gchar * gtk_file_chooser_get_uri (GtkFileChooser *chooser); |
191 | GDK_AVAILABLE_IN_ALL |
192 | gboolean gtk_file_chooser_set_uri (GtkFileChooser *chooser, |
193 | const char *uri); |
194 | GDK_AVAILABLE_IN_ALL |
195 | gboolean gtk_file_chooser_select_uri (GtkFileChooser *chooser, |
196 | const char *uri); |
197 | GDK_AVAILABLE_IN_ALL |
198 | void gtk_file_chooser_unselect_uri (GtkFileChooser *chooser, |
199 | const char *uri); |
200 | GDK_AVAILABLE_IN_ALL |
201 | GSList * gtk_file_chooser_get_uris (GtkFileChooser *chooser); |
202 | GDK_AVAILABLE_IN_ALL |
203 | gboolean gtk_file_chooser_set_current_folder_uri (GtkFileChooser *chooser, |
204 | const gchar *uri); |
205 | GDK_AVAILABLE_IN_ALL |
206 | gchar * gtk_file_chooser_get_current_folder_uri (GtkFileChooser *chooser); |
207 | |
208 | /* GFile manipulation */ |
209 | GDK_AVAILABLE_IN_ALL |
210 | GFile * gtk_file_chooser_get_file (GtkFileChooser *chooser); |
211 | GDK_AVAILABLE_IN_ALL |
212 | gboolean gtk_file_chooser_set_file (GtkFileChooser *chooser, |
213 | GFile *file, |
214 | GError **error); |
215 | GDK_AVAILABLE_IN_ALL |
216 | gboolean gtk_file_chooser_select_file (GtkFileChooser *chooser, |
217 | GFile *file, |
218 | GError **error); |
219 | GDK_AVAILABLE_IN_ALL |
220 | void gtk_file_chooser_unselect_file (GtkFileChooser *chooser, |
221 | GFile *file); |
222 | GDK_AVAILABLE_IN_ALL |
223 | GSList * gtk_file_chooser_get_files (GtkFileChooser *chooser); |
224 | GDK_AVAILABLE_IN_ALL |
225 | gboolean gtk_file_chooser_set_current_folder_file (GtkFileChooser *chooser, |
226 | GFile *file, |
227 | GError **error); |
228 | GDK_AVAILABLE_IN_ALL |
229 | GFile * gtk_file_chooser_get_current_folder_file (GtkFileChooser *chooser); |
230 | |
231 | /* Preview widget |
232 | */ |
233 | GDK_AVAILABLE_IN_ALL |
234 | void gtk_file_chooser_set_preview_widget (GtkFileChooser *chooser, |
235 | GtkWidget *preview_widget); |
236 | GDK_AVAILABLE_IN_ALL |
237 | GtkWidget *gtk_file_chooser_get_preview_widget (GtkFileChooser *chooser); |
238 | GDK_AVAILABLE_IN_ALL |
239 | void gtk_file_chooser_set_preview_widget_active (GtkFileChooser *chooser, |
240 | gboolean active); |
241 | GDK_AVAILABLE_IN_ALL |
242 | gboolean gtk_file_chooser_get_preview_widget_active (GtkFileChooser *chooser); |
243 | GDK_AVAILABLE_IN_ALL |
244 | void gtk_file_chooser_set_use_preview_label (GtkFileChooser *chooser, |
245 | gboolean use_label); |
246 | GDK_AVAILABLE_IN_ALL |
247 | gboolean gtk_file_chooser_get_use_preview_label (GtkFileChooser *chooser); |
248 | |
249 | GDK_AVAILABLE_IN_ALL |
250 | char *gtk_file_chooser_get_preview_filename (GtkFileChooser *chooser); |
251 | GDK_AVAILABLE_IN_ALL |
252 | char *gtk_file_chooser_get_preview_uri (GtkFileChooser *chooser); |
253 | GDK_AVAILABLE_IN_ALL |
254 | GFile *gtk_file_chooser_get_preview_file (GtkFileChooser *chooser); |
255 | |
256 | /* Extra widget |
257 | */ |
258 | GDK_AVAILABLE_IN_ALL |
259 | void (GtkFileChooser *chooser, |
260 | GtkWidget *); |
261 | GDK_AVAILABLE_IN_ALL |
262 | GtkWidget * (GtkFileChooser *chooser); |
263 | |
264 | /* List of user selectable filters |
265 | */ |
266 | GDK_AVAILABLE_IN_ALL |
267 | void gtk_file_chooser_add_filter (GtkFileChooser *chooser, |
268 | GtkFileFilter *filter); |
269 | GDK_AVAILABLE_IN_ALL |
270 | void gtk_file_chooser_remove_filter (GtkFileChooser *chooser, |
271 | GtkFileFilter *filter); |
272 | GDK_AVAILABLE_IN_ALL |
273 | GSList *gtk_file_chooser_list_filters (GtkFileChooser *chooser); |
274 | |
275 | /* Current filter |
276 | */ |
277 | GDK_AVAILABLE_IN_ALL |
278 | void gtk_file_chooser_set_filter (GtkFileChooser *chooser, |
279 | GtkFileFilter *filter); |
280 | GDK_AVAILABLE_IN_ALL |
281 | GtkFileFilter *gtk_file_chooser_get_filter (GtkFileChooser *chooser); |
282 | |
283 | /* Per-application shortcut folders */ |
284 | |
285 | GDK_AVAILABLE_IN_ALL |
286 | gboolean gtk_file_chooser_add_shortcut_folder (GtkFileChooser *chooser, |
287 | const char *folder, |
288 | GError **error); |
289 | GDK_AVAILABLE_IN_ALL |
290 | gboolean gtk_file_chooser_remove_shortcut_folder (GtkFileChooser *chooser, |
291 | const char *folder, |
292 | GError **error); |
293 | GDK_AVAILABLE_IN_ALL |
294 | GSList *gtk_file_chooser_list_shortcut_folders (GtkFileChooser *chooser); |
295 | |
296 | GDK_AVAILABLE_IN_ALL |
297 | gboolean gtk_file_chooser_add_shortcut_folder_uri (GtkFileChooser *chooser, |
298 | const char *uri, |
299 | GError **error); |
300 | GDK_AVAILABLE_IN_ALL |
301 | gboolean gtk_file_chooser_remove_shortcut_folder_uri (GtkFileChooser *chooser, |
302 | const char *uri, |
303 | GError **error); |
304 | GDK_AVAILABLE_IN_ALL |
305 | GSList *gtk_file_chooser_list_shortcut_folder_uris (GtkFileChooser *chooser); |
306 | |
307 | GDK_AVAILABLE_IN_3_22 |
308 | void gtk_file_chooser_add_choice (GtkFileChooser *chooser, |
309 | const char *id, |
310 | const char *label, |
311 | const char **options, |
312 | const char **option_labels); |
313 | GDK_AVAILABLE_IN_3_22 |
314 | void gtk_file_chooser_remove_choice (GtkFileChooser *chooser, |
315 | const char *id); |
316 | GDK_AVAILABLE_IN_3_22 |
317 | void gtk_file_chooser_set_choice (GtkFileChooser *chooser, |
318 | const char *id, |
319 | const char *option); |
320 | GDK_AVAILABLE_IN_3_22 |
321 | const char *gtk_file_chooser_get_choice (GtkFileChooser *chooser, |
322 | const char *id); |
323 | |
324 | G_END_DECLS |
325 | |
326 | #endif /* __GTK_FILE_CHOOSER_H__ */ |
327 | |