1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD 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
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module gtk.FileChooserIF;
26 
27 private import gio.FileIF;
28 private import gio.ListModelIF;
29 private import glib.ErrorG;
30 private import glib.GException;
31 private import glib.Str;
32 private import glib.c.functions;
33 private import gobject.ObjectG;
34 private import gtk.FileFilter;
35 private import gtk.c.functions;
36 public  import gtk.c.types;
37 
38 
39 /**
40  * `GtkFileChooser` is an interface that can be implemented by file
41  * selection widgets.
42  * 
43  * In GTK, the main objects that implement this interface are
44  * [class@Gtk.FileChooserWidget] and [class@Gtk.FileChooserDialog].
45  * 
46  * You do not need to write an object that implements the `GtkFileChooser`
47  * interface unless you are trying to adapt an existing file selector to
48  * expose a standard programming interface.
49  * 
50  * `GtkFileChooser` allows for shortcuts to various places in the filesystem.
51  * In the default implementation these are displayed in the left pane. It
52  * may be a bit confusing at first that these shortcuts come from various
53  * sources and in various flavours, so lets explain the terminology here:
54  * 
55  * - Bookmarks: are created by the user, by dragging folders from the
56  * right pane to the left pane, or by using the “Add”. Bookmarks
57  * can be renamed and deleted by the user.
58  * 
59  * - Shortcuts: can be provided by the application. For example, a Paint
60  * program may want to add a shortcut for a Clipart folder. Shortcuts
61  * cannot be modified by the user.
62  * 
63  * - Volumes: are provided by the underlying filesystem abstraction. They are
64  * the “roots” of the filesystem.
65  * 
66  * # File Names and Encodings
67  * 
68  * When the user is finished selecting files in a `GtkFileChooser`, your
69  * program can get the selected filenames as `GFile`s.
70  * 
71  * # Adding options
72  * 
73  * You can add extra widgets to a file chooser to provide options
74  * that are not present in the default design, by using
75  * [method@Gtk.FileChooser.add_choice]. Each choice has an identifier and
76  * a user visible label; additionally, each choice can have multiple
77  * options. If a choice has no option, it will be rendered as a
78  * check button with the given label; if a choice has options, it will
79  * be rendered as a combo box.
80  */
81 public interface FileChooserIF{
82 	/** Get the main Gtk struct */
83 	public GtkFileChooser* getFileChooserStruct(bool transferOwnership = false);
84 
85 	/** the main Gtk struct as a void* */
86 	protected void* getStruct();
87 
88 
89 	/** */
90 	public static GType getType()
91 	{
92 		return gtk_file_chooser_get_type();
93 	}
94 
95 	/**
96 	 * Adds a 'choice' to the file chooser.
97 	 *
98 	 * This is typically implemented as a combobox or, for boolean choices,
99 	 * as a checkbutton. You can select a value using
100 	 * [method@Gtk.FileChooser.set_choice] before the dialog is shown,
101 	 * and you can obtain the user-selected value in the
102 	 * [signal@Gtk.Dialog::response] signal handler using
103 	 * [method@Gtk.FileChooser.get_choice].
104 	 *
105 	 * Params:
106 	 *     id = id for the added choice
107 	 *     label = user-visible label for the added choice
108 	 *     options = ids for the options of the choice, or %NULL for a boolean choice
109 	 *     optionLabels = user-visible labels for the options, must be the same length as @options
110 	 */
111 	public void addChoice(string id, string label, string[] options, string[] optionLabels);
112 
113 	/**
114 	 * Adds @filter to the list of filters that the user can select between.
115 	 *
116 	 * When a filter is selected, only files that are passed by that
117 	 * filter are displayed.
118 	 *
119 	 * Note that the @chooser takes ownership of the filter if it is floating,
120 	 * so you have to ref and sink it if you want to keep a reference.
121 	 *
122 	 * Params:
123 	 *     filter = a `GtkFileFilter`
124 	 */
125 	public void addFilter(FileFilter filter);
126 
127 	/**
128 	 * Adds a folder to be displayed with the shortcut folders
129 	 * in a file chooser.
130 	 *
131 	 * Params:
132 	 *     folder = a `GFile` for the folder to add
133 	 *
134 	 * Returns: %TRUE if the folder could be added successfully,
135 	 *     %FALSE otherwise.
136 	 *
137 	 * Throws: GException on failure.
138 	 */
139 	public bool addShortcutFolder(FileIF folder);
140 
141 	/**
142 	 * Gets the type of operation that the file chooser is performing.
143 	 *
144 	 * Returns: the action that the file selector is performing
145 	 */
146 	public GtkFileChooserAction getAction();
147 
148 	/**
149 	 * Gets the currently selected option in the 'choice' with the given ID.
150 	 *
151 	 * Params:
152 	 *     id = the ID of the choice to get
153 	 *
154 	 * Returns: the ID of the currently selected option
155 	 */
156 	public string getChoice(string id);
157 
158 	/**
159 	 * Gets whether file chooser will offer to create new folders.
160 	 *
161 	 * Returns: %TRUE if the Create Folder button should be displayed.
162 	 */
163 	public bool getCreateFolders();
164 
165 	/**
166 	 * Gets the current folder of @chooser as #GFile.
167 	 *
168 	 * Returns: the `GFile` for the current folder.
169 	 */
170 	public FileIF getCurrentFolder();
171 
172 	/**
173 	 * Gets the current name in the file selector, as entered by the user.
174 	 *
175 	 * This is meant to be used in save dialogs, to get the currently typed
176 	 * filename when the file itself does not exist yet.
177 	 *
178 	 * Returns: The raw text from the file chooser’s “Name” entry. Free with
179 	 *     g_free(). Note that this string is not a full pathname or URI; it is
180 	 *     whatever the contents of the entry are. Note also that this string is
181 	 *     in UTF-8 encoding, which is not necessarily the system’s encoding for
182 	 *     filenames.
183 	 */
184 	public string getCurrentName();
185 
186 	/**
187 	 * Gets the `GFile` for the currently selected file in
188 	 * the file selector.
189 	 *
190 	 * If multiple files are selected, one of the files will be
191 	 * returned at random.
192 	 *
193 	 * If the file chooser is in folder mode, this function returns
194 	 * the selected folder.
195 	 *
196 	 * Returns: a selected `GFile`. You own the
197 	 *     returned file; use g_object_unref() to release it.
198 	 */
199 	public FileIF getFile();
200 
201 	/**
202 	 * Lists all the selected files and subfolders in the current folder
203 	 * of @chooser as #GFile.
204 	 *
205 	 * Returns: a list model containing a `GFile` for each
206 	 *     selected file and subfolder in the current folder. Free the returned
207 	 *     list with g_object_unref().
208 	 */
209 	public ListModelIF getFiles();
210 
211 	/**
212 	 * Gets the current filter.
213 	 *
214 	 * Returns: the current filter, or %NULL
215 	 */
216 	public FileFilter getFilter();
217 
218 	/**
219 	 * Gets the current set of user-selectable filters, as a list model.
220 	 *
221 	 * See [method@Gtk.FileChooser.add_filter] and
222 	 * [method@Gtk.FileChooser.remove_filter] for changing individual filters.
223 	 *
224 	 * You should not modify the returned list model. Future changes to
225 	 * @chooser may or may not affect the returned model.
226 	 *
227 	 * Returns: a `GListModel` containing the current set
228 	 *     of user-selectable filters.
229 	 */
230 	public ListModelIF getFilters();
231 
232 	/**
233 	 * Gets whether multiple files can be selected in the file
234 	 * chooser.
235 	 *
236 	 * Returns: %TRUE if multiple files can be selected.
237 	 */
238 	public bool getSelectMultiple();
239 
240 	/**
241 	 * Queries the list of shortcut folders in the file chooser.
242 	 *
243 	 * You should not modify the returned list model. Future changes to
244 	 * @chooser may or may not affect the returned model.
245 	 *
246 	 * Returns: A list model of `GFile`s
247 	 */
248 	public ListModelIF getShortcutFolders();
249 
250 	/**
251 	 * Removes a 'choice' that has been added with gtk_file_chooser_add_choice().
252 	 *
253 	 * Params:
254 	 *     id = the ID of the choice to remove
255 	 */
256 	public void removeChoice(string id);
257 
258 	/**
259 	 * Removes @filter from the list of filters that the user can select between.
260 	 *
261 	 * Params:
262 	 *     filter = a `GtkFileFilter`
263 	 */
264 	public void removeFilter(FileFilter filter);
265 
266 	/**
267 	 * Removes a folder from the shortcut folders in a file chooser.
268 	 *
269 	 * Params:
270 	 *     folder = a `GFile` for the folder to remove
271 	 *
272 	 * Returns: %TRUE if the folder could be removed successfully,
273 	 *     %FALSE otherwise.
274 	 *
275 	 * Throws: GException on failure.
276 	 */
277 	public bool removeShortcutFolder(FileIF folder);
278 
279 	/**
280 	 * Sets the type of operation that the chooser is performing.
281 	 *
282 	 * The user interface is adapted to suit the selected action.
283 	 *
284 	 * For example, an option to create a new folder might be shown
285 	 * if the action is %GTK_FILE_CHOOSER_ACTION_SAVE but not if the
286 	 * action is %GTK_FILE_CHOOSER_ACTION_OPEN.
287 	 *
288 	 * Params:
289 	 *     action = the action that the file selector is performing
290 	 */
291 	public void setAction(GtkFileChooserAction action);
292 
293 	/**
294 	 * Selects an option in a 'choice' that has been added with
295 	 * gtk_file_chooser_add_choice().
296 	 *
297 	 * For a boolean choice, the possible options are "true" and "false".
298 	 *
299 	 * Params:
300 	 *     id = the ID of the choice to set
301 	 *     option = the ID of the option to select
302 	 */
303 	public void setChoice(string id, string option);
304 
305 	/**
306 	 * Sets whether file chooser will offer to create new folders.
307 	 *
308 	 * This is only relevant if the action is not set to be
309 	 * %GTK_FILE_CHOOSER_ACTION_OPEN.
310 	 *
311 	 * Params:
312 	 *     createFolders = %TRUE if the Create Folder button should be displayed
313 	 */
314 	public void setCreateFolders(bool createFolders);
315 
316 	/**
317 	 * Sets the current folder for @chooser from a #GFile.
318 	 *
319 	 * Params:
320 	 *     file = the `GFile` for the new folder
321 	 *
322 	 * Returns: %TRUE if the folder could be changed successfully, %FALSE
323 	 *     otherwise.
324 	 *
325 	 * Throws: GException on failure.
326 	 */
327 	public bool setCurrentFolder(FileIF file);
328 
329 	/**
330 	 * Sets the current name in the file selector, as if entered
331 	 * by the user.
332 	 *
333 	 * Note that the name passed in here is a UTF-8 string rather
334 	 * than a filename. This function is meant for such uses as a
335 	 * suggested name in a “Save As...” dialog.  You can pass
336 	 * “Untitled.doc” or a similarly suitable suggestion for the @name.
337 	 *
338 	 * If you want to preselect a particular existing file, you should
339 	 * use [method@Gtk.FileChooser.set_file] instead.
340 	 *
341 	 * Please see the documentation for those functions for an example
342 	 * of using [method@Gtk.FileChooser.set_current_name] as well.
343 	 *
344 	 * Params:
345 	 *     name = the filename to use, as a UTF-8 string
346 	 */
347 	public void setCurrentName(string name);
348 
349 	/**
350 	 * Sets @file as the current filename for the file chooser.
351 	 *
352 	 * This includes changing to the file’s parent folder and actually selecting
353 	 * the file in list. If the @chooser is in %GTK_FILE_CHOOSER_ACTION_SAVE mode,
354 	 * the file’s base name will also appear in the dialog’s file name entry.
355 	 *
356 	 * If the file name isn’t in the current folder of @chooser, then the current
357 	 * folder of @chooser will be changed to the folder containing @filename.
358 	 *
359 	 * Note that the file must exist, or nothing will be done except
360 	 * for the directory change.
361 	 *
362 	 * If you are implementing a save dialog, you should use this function if
363 	 * you already have a file name to which the user may save; for example,
364 	 * when the user opens an existing file and then does “Save As…”. If you
365 	 * don’t have a file name already — for example, if the user just created
366 	 * a new file and is saving it for the first time, do not call this function.
367 	 *
368 	 * Instead, use something similar to this:
369 	 *
370 	 * ```c
371 	 * static void
372 	 * prepare_file_chooser (GtkFileChooser *chooser,
373 	 * GFile          *existing_file)
374 	 * {
375 	 * gboolean document_is_new = (existing_file == NULL);
376 	 *
377 	 * if (document_is_new)
378 	 * {
379 	 * GFile *default_file_for_saving = g_file_new_for_path ("./out.txt");
380 	 * // the user just created a new document
381 	 * gtk_file_chooser_set_current_folder (chooser, default_file_for_saving, NULL);
382 	 * gtk_file_chooser_set_current_name (chooser, "Untitled document");
383 	 * g_object_unref (default_file_for_saving);
384 	 * }
385 	 * else
386 	 * {
387 	 * // the user edited an existing document
388 	 * gtk_file_chooser_set_file (chooser, existing_file, NULL);
389 	 * }
390 	 * }
391 	 * ```
392 	 *
393 	 * Params:
394 	 *     file = the `GFile` to set as current
395 	 *
396 	 * Returns: Not useful
397 	 *
398 	 * Throws: GException on failure.
399 	 */
400 	public bool setFile(FileIF file);
401 
402 	/**
403 	 * Sets the current filter.
404 	 *
405 	 * Only the files that pass the filter will be displayed.
406 	 * If the user-selectable list of filters is non-empty, then
407 	 * the filter should be one of the filters in that list.
408 	 *
409 	 * Setting the current filter when the list of filters is
410 	 * empty is useful if you want to restrict the displayed
411 	 * set of files without letting the user change it.
412 	 *
413 	 * Params:
414 	 *     filter = a `GtkFileFilter`
415 	 */
416 	public void setFilter(FileFilter filter);
417 
418 	/**
419 	 * Sets whether multiple files can be selected in the file chooser.
420 	 *
421 	 * This is only relevant if the action is set to be
422 	 * %GTK_FILE_CHOOSER_ACTION_OPEN or
423 	 * %GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER.
424 	 *
425 	 * Params:
426 	 *     selectMultiple = %TRUE if multiple files can be selected.
427 	 */
428 	public void setSelectMultiple(bool selectMultiple);
429 }