1 /* GTK - The GIMP Toolkit
2 * gtkfilechooser.c: Abstract interface for file selector GUIs
3 * Copyright (C) 2003, Red Hat, Inc.
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.
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.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
22 #include "gtkfilechooser.h"
23 #include "gtkfilechooserprivate.h"
24 #include "gtkfilesystem.h"
26 #include "gtktypebuiltins.h"
27 #include "gtkprivate.h"
28 #include "gtkmarshalers.h"
31 static void gtk_file_chooser_class_init (gpointer g_iface);
33 static GtkFilePath *gtk_file_chooser_get_path (GtkFileChooser *chooser);
36 gtk_file_chooser_get_type (void)
38 static GType file_chooser_type = 0;
40 if (!file_chooser_type)
42 file_chooser_type = g_type_register_static_simple (G_TYPE_INTERFACE,
44 sizeof (GtkFileChooserIface),
45 (GClassInitFunc) gtk_file_chooser_class_init,
48 g_type_interface_add_prerequisite (file_chooser_type, GTK_TYPE_WIDGET);
51 return file_chooser_type;
55 confirm_overwrite_accumulator (GSignalInvocationHint *ihint,
57 const GValue *handler_return,
60 gboolean continue_emission;
61 GtkFileChooserConfirmation conf;
63 conf = g_value_get_enum (handler_return);
64 g_value_set_enum (return_accu, conf);
65 continue_emission = (conf == GTK_FILE_CHOOSER_CONFIRMATION_CONFIRM);
67 return continue_emission;
71 gtk_file_chooser_class_init (gpointer g_iface)
73 GType iface_type = G_TYPE_FROM_INTERFACE (g_iface);
76 * GtkFileChooser::current-folder-changed
77 * @chooser: the object which received the signal.
79 * This signal is emitted when the current folder in a #GtkFileChooser
80 * changes. This can happen due to the user performing some action that
81 * changes folders, such as selecting a bookmark or visiting a folder on the
82 * file list. It can also happen as a result of calling a function to
83 * explicitly change the current folder in a file chooser.
85 * Normally you do not need to connect to this signal, unless you need to keep
86 * track of which folder a file chooser is showing.
88 * See also: gtk_file_chooser_set_current_folder(),
89 * gtk_file_chooser_get_current_folder(),
90 * gtk_file_chooser_set_current_folder_uri(),
91 * gtk_file_chooser_get_current_folder_uri().
93 g_signal_new (I_("current-folder-changed"),
96 G_STRUCT_OFFSET (GtkFileChooserIface, current_folder_changed),
98 g_cclosure_marshal_VOID__VOID,
102 * GtkFileChooser::selection-changed
103 * @chooser: the object which received the signal.
105 * This signal is emitted when there is a change in the set of selected files
106 * in a #GtkFileChooser. This can happen when the user modifies the selection
107 * with the mouse or the keyboard, or when explicitly calling functions to
108 * change the selection.
110 * Normally you do not need to connect to this signal, as it is easier to wait
111 * for the file chooser to finish running, and then to get the list of
112 * selected files using the functions mentioned below.
114 * See also: gtk_file_chooser_select_filename(),
115 * gtk_file_chooser_unselect_filename(), gtk_file_chooser_get_filename(),
116 * gtk_file_chooser_get_filenames(), gtk_file_chooser_select_uri(),
117 * gtk_file_chooser_unselect_uri(), gtk_file_chooser_get_uri(),
118 * gtk_file_chooser_get_uris().
120 g_signal_new (I_("selection-changed"),
123 G_STRUCT_OFFSET (GtkFileChooserIface, selection_changed),
125 g_cclosure_marshal_VOID__VOID,
129 * GtkFileChooser::update-preview
130 * @chooser: the object which received the signal.
132 * This signal is emitted when the preview in a file chooser should be
133 * regenerated. For example, this can happen when the currently selected file
134 * changes. You should use this signal if you want your file chooser to have
137 * Once you have installed a preview widget with
138 * gtk_file_chooser_set_preview_widget(), you should update it when this
139 * signal is emitted. You can use the functions
140 * gtk_file_chooser_get_preview_filename() or
141 * gtk_file_chooser_get_preview_uri() to get the name of the file to preview.
142 * Your widget may not be able to preview all kinds of files; your callback
143 * must call gtk_file_chooser_set_preview_wiget_active() to inform the file
144 * chooser about whether the preview was generated successfully or not.
146 * Please see the example code in <xref linkend="gtkfilechooser-preview"/>.
148 * See also: gtk_file_chooser_set_preview_widget(),
149 * gtk_file_chooser_set_preview_widget_active(),
150 * gtk_file_chooser_set_use_preview_label(),
151 * gtk_file_chooser_get_preview_filename(),
152 * gtk_file_chooser_get_preview_uri().
154 g_signal_new (I_("update-preview"),
157 G_STRUCT_OFFSET (GtkFileChooserIface, update_preview),
159 g_cclosure_marshal_VOID__VOID,
163 * GtkFileChooser::file-activated
164 * @chooser: the object which received the signal.
166 * This signal is emitted when the user "activates" a file in the file
167 * chooser. This can happen by double-clicking on a file in the file list, or
168 * by pressing <keycap>Enter</keycap>.
170 * Normally you do not need to connect to this signal. It is used internally
171 * by #GtkFileChooserDialog to know when to activate the default button in the
174 * See also: gtk_file_chooser_get_filename(),
175 * gtk_file_chooser_get_filenames(), gtk_file_chooser_get_uri(),
176 * gtk_file_chooser_get_uris().
178 g_signal_new (I_("file-activated"),
181 G_STRUCT_OFFSET (GtkFileChooserIface, file_activated),
183 g_cclosure_marshal_VOID__VOID,
186 /* Documented in the docbook files */
187 g_signal_new (I_("confirm-overwrite"),
190 G_STRUCT_OFFSET (GtkFileChooserIface, confirm_overwrite),
191 confirm_overwrite_accumulator, NULL,
192 _gtk_marshal_ENUM__VOID,
193 GTK_TYPE_FILE_CHOOSER_CONFIRMATION, 0);
195 g_object_interface_install_property (g_iface,
196 g_param_spec_enum ("action",
198 P_("The type of operation that the file selector is performing"),
199 GTK_TYPE_FILE_CHOOSER_ACTION,
200 GTK_FILE_CHOOSER_ACTION_OPEN,
201 GTK_PARAM_READWRITE));
202 g_object_interface_install_property (g_iface,
203 g_param_spec_string ("file-system-backend",
204 P_("File System Backend"),
205 P_("Name of file system backend to use"),
207 GTK_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
208 g_object_interface_install_property (g_iface,
209 g_param_spec_object ("filter",
211 P_("The current filter for selecting which files are displayed"),
212 GTK_TYPE_FILE_FILTER,
213 GTK_PARAM_READWRITE));
214 g_object_interface_install_property (g_iface,
215 g_param_spec_boolean ("local-only",
217 P_("Whether the selected file(s) should be limited to local file: URLs"),
219 GTK_PARAM_READWRITE));
220 g_object_interface_install_property (g_iface,
221 g_param_spec_object ("preview-widget",
222 P_("Preview widget"),
223 P_("Application supplied widget for custom previews."),
225 GTK_PARAM_READWRITE));
226 g_object_interface_install_property (g_iface,
227 g_param_spec_boolean ("preview-widget-active",
228 P_("Preview Widget Active"),
229 P_("Whether the application supplied widget for custom previews should be shown."),
231 GTK_PARAM_READWRITE));
232 g_object_interface_install_property (g_iface,
233 g_param_spec_boolean ("use-preview-label",
234 P_("Use Preview Label"),
235 P_("Whether to display a stock label with the name of the previewed file."),
237 GTK_PARAM_READWRITE));
238 g_object_interface_install_property (g_iface,
239 g_param_spec_object ("extra-widget",
241 P_("Application supplied widget for extra options."),
243 GTK_PARAM_READWRITE));
244 g_object_interface_install_property (g_iface,
245 g_param_spec_boolean ("select-multiple",
246 P_("Select Multiple"),
247 P_("Whether to allow multiple files to be selected"),
249 GTK_PARAM_READWRITE));
251 g_object_interface_install_property (g_iface,
252 g_param_spec_boolean ("show-hidden",
254 P_("Whether the hidden files and folders should be displayed"),
256 GTK_PARAM_READWRITE));
259 * GtkFileChooser:do-overwrite-confirmation:
261 * Whether a file chooser in %GTK_FILE_CHOOSER_ACTION_SAVE mode
262 * will present an overwrite confirmation dialog if the user
263 * selects a file name that already exists.
267 g_object_interface_install_property (g_iface,
268 g_param_spec_boolean ("do-overwrite-confirmation",
269 P_("Do overwrite confirmation"),
270 P_("Whether a file chooser in save mode "
271 "will present an overwrite confirmation dialog "
274 GTK_PARAM_READWRITE));
278 * gtk_file_chooser_error_quark:
280 * Registers an error quark for #GtkFileChooser if necessary.
282 * Return value: The error quark used for #GtkFileChooser errors.
287 gtk_file_chooser_error_quark (void)
289 return g_quark_from_static_string ("gtk-file-chooser-error-quark");
293 * gtk_file_chooser_set_action:
294 * @chooser: a #GtkFileChooser
295 * @action: the action that the file selector is performing
297 * Sets the type of operation that the chooser is performing; the
298 * user interface is adapted to suit the selected action. For example,
299 * an option to create a new folder might be shown if the action is
300 * %GTK_FILE_CHOOSER_ACTION_SAVE but not if the action is
301 * %GTK_FILE_CHOOSER_ACTION_OPEN.
306 gtk_file_chooser_set_action (GtkFileChooser *chooser,
307 GtkFileChooserAction action)
309 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
311 g_object_set (chooser, "action", action, NULL);
315 * gtk_file_chooser_get_action:
316 * @chooser: a #GtkFileChooser
318 * Gets the type of operation that the file chooser is performing; see
319 * gtk_file_chooser_set_action().
321 * Return value: the action that the file selector is performing
326 gtk_file_chooser_get_action (GtkFileChooser *chooser)
328 GtkFileChooserAction action;
330 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
332 g_object_get (chooser, "action", &action, NULL);
338 * gtk_file_chooser_set_local_only:
339 * @chooser: a #GtkFileChooser
340 * @local_only: %TRUE if only local files can be selected
342 * Sets whether only local files can be selected in the
343 * file selector. If @local_only is %TRUE (the default),
344 * then the selected file are files are guaranteed to be
345 * accessible through the operating systems native file
346 * file system and therefore the application only
347 * needs to worry about the filename functions in
348 * #GtkFileChooser, like gtk_file_chooser_get_filename(),
349 * rather than the URI functions like
350 * gtk_file_chooser_get_uri(),
355 gtk_file_chooser_set_local_only (GtkFileChooser *chooser,
358 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
360 g_object_set (chooser, "local-only", local_only, NULL);
364 * gtk_file_chooser_get_local_only:
365 * @chooser: a #GtkFileChoosre
367 * Gets whether only local files can be selected in the
368 * file selector. See gtk_file_chooser_set_local_only()
370 * Return value: %TRUE if only local files can be selected.
375 gtk_file_chooser_get_local_only (GtkFileChooser *chooser)
379 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
381 g_object_get (chooser, "local-only", &local_only, NULL);
387 * gtk_file_chooser_set_select_multiple:
388 * @chooser: a #GtkFileChooser
389 * @select_multiple: %TRUE if multiple files can be selected.
391 * Sets whether multiple files can be selected in the file selector. This is
392 * only relevant if the action is set to be GTK_FILE_CHOOSER_ACTION_OPEN or
393 * GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER.
398 gtk_file_chooser_set_select_multiple (GtkFileChooser *chooser,
399 gboolean select_multiple)
401 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
403 g_object_set (chooser, "select-multiple", select_multiple, NULL);
407 * gtk_file_chooser_get_select_multiple:
408 * @chooser: a #GtkFileChooser
410 * Gets whether multiple files can be selected in the file
411 * selector. See gtk_file_chooser_set_select_multiple().
413 * Return value: %TRUE if multiple files can be selected.
418 gtk_file_chooser_get_select_multiple (GtkFileChooser *chooser)
420 gboolean select_multiple;
422 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
424 g_object_get (chooser, "select-multiple", &select_multiple, NULL);
426 return select_multiple;
430 * gtk_file_chooser_get_filename:
431 * @chooser: a #GtkFileChooser
433 * Gets the filename for the currently selected file in
434 * the file selector. If multiple files are selected,
435 * one of the filenames will be returned at random.
437 * If the file chooser is in folder mode, this function returns the selected
440 * Return value: The currently selected filename, or %NULL
441 * if no file is selected, or the selected file can't
442 * be represented with a local filename. Free with g_free().
447 gtk_file_chooser_get_filename (GtkFileChooser *chooser)
449 GtkFileSystem *file_system;
451 gchar *result = NULL;
453 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
455 file_system = _gtk_file_chooser_get_file_system (chooser);
456 path = gtk_file_chooser_get_path (chooser);
459 result = gtk_file_system_path_to_filename (file_system, path);
460 gtk_file_path_free (path);
467 * gtk_file_chooser_set_filename:
468 * @chooser: a #GtkFileChooser
469 * @filename: the filename to set as current
471 * Sets @filename as the current filename for the file chooser, by changing
472 * to the file's parent folder and actually selecting the file in list. If
473 * the @chooser is in #GTK_FILE_CHOOSER_ACTION_SAVE mode, the file's base name
474 * will also appear in the dialog's file name entry.
476 * If the file name isn't in the current folder of @chooser, then the current
477 * folder of @chooser will be changed to the folder containing @filename. This
478 * is equivalent to a sequence of gtk_file_chooser_unselect_all() followed by
479 * gtk_file_chooser_select_filename().
481 * Note that the file must exist, or nothing will be done except
482 * for the directory change.
484 * If you are implementing a <guimenuitem>File/Save As...</guimenuitem> dialog, you
485 * should use this function if you already have a file name to which the user may save; for example,
486 * when the user opens an existing file and then does <guimenuitem>File/Save As...</guimenuitem>
487 * on it. If you don't have a file name already — for example, if the user just created
488 * a new file and is saving it for the first time, do not call this function. Instead, use
489 * something similar to this:
492 * if (document_is_new)
494 * /<!-- -->* the user just created a new document *<!-- -->/
495 * gtk_file_chooser_set_current_folder (chooser, default_folder_for_saving);
496 * gtk_file_chooser_set_current_name (chooser, "Untitled document");
500 * /<!-- -->* the user edited an existing document *<!-- -->/
501 * gtk_file_chooser_set_filename (chooser, existing_filename);
505 * Return value: %TRUE if both the folder could be changed and the file was
506 * selected successfully, %FALSE otherwise.
511 gtk_file_chooser_set_filename (GtkFileChooser *chooser,
512 const gchar *filename)
514 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
516 gtk_file_chooser_unselect_all (chooser);
517 return gtk_file_chooser_select_filename (chooser, filename);
521 * gtk_file_chooser_select_filename:
522 * @chooser: a #GtkFileChooser
523 * @filename: the filename to select
525 * Selects a filename. If the file name isn't in the current
526 * folder of @chooser, then the current folder of @chooser will
527 * be changed to the folder containing @filename.
529 * Return value: %TRUE if both the folder could be changed and the file was
530 * selected successfully, %FALSE otherwise.
535 gtk_file_chooser_select_filename (GtkFileChooser *chooser,
536 const gchar *filename)
538 GtkFileSystem *file_system;
542 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
543 g_return_val_if_fail (filename != NULL, FALSE);
545 file_system = _gtk_file_chooser_get_file_system (chooser);
547 path = gtk_file_system_filename_to_path (file_system, filename);
550 result = _gtk_file_chooser_select_path (chooser, path, NULL);
551 gtk_file_path_free (path);
560 * gtk_file_chooser_unselect_filename:
561 * @chooser: a #GtkFileChooser
562 * @filename: the filename to unselect
564 * Unselects a currently selected filename. If the filename
565 * is not in the current directory, does not exist, or
566 * is otherwise not currently selected, does nothing.
571 gtk_file_chooser_unselect_filename (GtkFileChooser *chooser,
572 const char *filename)
574 GtkFileSystem *file_system;
577 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
578 g_return_if_fail (filename != NULL);
580 file_system = _gtk_file_chooser_get_file_system (chooser);
582 path = gtk_file_system_filename_to_path (file_system, filename);
585 _gtk_file_chooser_unselect_path (chooser, path);
586 gtk_file_path_free (path);
590 /* Converts a list of GtkFilePath* to a list of strings using the specified function */
592 file_paths_to_strings (GtkFileSystem *fs,
594 gchar * (*convert_func) (GtkFileSystem *fs, const GtkFilePath *path))
600 for (; paths; paths = paths->next)
606 string = (* convert_func) (fs, path);
609 strings = g_slist_prepend (strings, string);
612 return g_slist_reverse (strings);
616 * gtk_file_chooser_get_filenames:
617 * @chooser: a #GtkFileChooser
619 * Lists all the selected files and subfolders in the current folder of
620 * @chooser. The returned names are full absolute paths. If files in the current
621 * folder cannot be represented as local filenames they will be ignored. (See
622 * gtk_file_chooser_get_uris())
624 * Return value: a #GSList containing the filenames of all selected
625 * files and subfolders in the current folder. Free the returned list
626 * with g_slist_free(), and the filenames with g_free().
631 gtk_file_chooser_get_filenames (GtkFileChooser *chooser)
633 GtkFileSystem *file_system;
637 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
639 file_system = _gtk_file_chooser_get_file_system (chooser);
640 paths = _gtk_file_chooser_get_paths (chooser);
642 result = file_paths_to_strings (file_system, paths, gtk_file_system_path_to_filename);
643 gtk_file_paths_free (paths);
648 * gtk_file_chooser_set_current_folder:
649 * @chooser: a #GtkFileChooser
650 * @filename: the full path of the new current folder
652 * Sets the current folder for @chooser from a local filename.
653 * The user will be shown the full contents of the current folder,
654 * plus user interface elements for navigating to other folders.
656 * Return value: %TRUE if the folder could be changed successfully, %FALSE
662 gtk_file_chooser_set_current_folder (GtkFileChooser *chooser,
663 const gchar *filename)
665 GtkFileSystem *file_system;
669 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
670 g_return_val_if_fail (filename != NULL, FALSE);
672 file_system = _gtk_file_chooser_get_file_system (chooser);
674 path = gtk_file_system_filename_to_path (file_system, filename);
677 result = _gtk_file_chooser_set_current_folder_path (chooser, path, NULL);
678 gtk_file_path_free (path);
687 * gtk_file_chooser_get_current_folder:
688 * @chooser: a #GtkFileChooser
690 * Gets the current folder of @chooser as a local filename.
691 * See gtk_file_chooser_set_current_folder().
693 * Note that this is the folder that the file chooser is currently displaying
694 * (e.g. "/home/username/Documents"), which is <emphasis>not the same</emphasis>
695 * as the currently-selected folder if the chooser is in
696 * #GTK_FILE_CHOOSER_SELECT_FOLDER mode
697 * (e.g. "/home/username/Documents/selected-folder/". To get the
698 * currently-selected folder in that mode, use gtk_file_chooser_get_uri() as the
699 * usual way to get the selection.
701 * Return value: the full path of the current folder, or %NULL if the current
702 * path cannot be represented as a local filename. Free with g_free(). This
703 * function will also return %NULL if the file chooser was unable to load the
704 * last folder that was requested from it; for example, as would be for calling
705 * gtk_file_chooser_set_current_folder() on a nonexistent folder.
710 gtk_file_chooser_get_current_folder (GtkFileChooser *chooser)
712 GtkFileSystem *file_system;
716 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
718 file_system = _gtk_file_chooser_get_file_system (chooser);
720 path = _gtk_file_chooser_get_current_folder_path (chooser);
724 filename = gtk_file_system_path_to_filename (file_system, path);
725 gtk_file_path_free (path);
731 * gtk_file_chooser_set_current_name:
732 * @chooser: a #GtkFileChooser
733 * @name: the filename to use, as a UTF-8 string
735 * Sets the current name in the file selector, as if entered
736 * by the user. Note that the name passed in here is a UTF-8
737 * string rather than a filename. This function is meant for
738 * such uses as a suggested name in a "Save As..." dialog.
740 * If you want to preselect a particular existing file, you should use
741 * gtk_file_chooser_set_filename() or gtk_file_chooser_set_uri() instead.
742 * Please see the documentation for those functions for an example of using
743 * gtk_file_chooser_set_current_name() as well.
748 gtk_file_chooser_set_current_name (GtkFileChooser *chooser,
751 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
752 g_return_if_fail (name != NULL);
754 GTK_FILE_CHOOSER_GET_IFACE (chooser)->set_current_name (chooser, name);
758 * gtk_file_chooser_get_uri:
759 * @chooser: a #GtkFileChooser
761 * Gets the URI for the currently selected file in
762 * the file selector. If multiple files are selected,
763 * one of the filenames will be returned at random.
765 * If the file chooser is in folder mode, this function returns the selected
768 * Return value: The currently selected URI, or %NULL
769 * if no file is selected. Free with g_free()
774 gtk_file_chooser_get_uri (GtkFileChooser *chooser)
776 GtkFileSystem *file_system;
778 gchar *result = NULL;
780 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
782 file_system = _gtk_file_chooser_get_file_system (chooser);
783 path = gtk_file_chooser_get_path (chooser);
786 result = gtk_file_system_path_to_uri (file_system, path);
787 gtk_file_path_free (path);
794 * gtk_file_chooser_set_uri:
795 * @chooser: a #GtkFileChooser
796 * @uri: the URI to set as current
798 * Sets the file referred to by @uri as the current file for the file chooser,
799 * by changing to the URI's parent folder and actually selecting the URI in the
800 * list. If the @chooser is #GTK_FILE_CHOOSER_ACTION_SAVE mode, the URI's base
801 * name will also appear in the dialog's file name entry.
803 * If the URI isn't in the current folder of @chooser, then the current folder
804 * of @chooser will be changed to the folder containing @uri. This is equivalent
805 * to a sequence of gtk_file_chooser_unselect_all() followed by
806 * gtk_file_chooser_select_uri().
808 * Note that the URI must exist, or nothing will be done except
809 * for the directory change.
810 * If you are implementing a <guimenuitem>File/Save As...</guimenuitem> dialog, you
811 * should use this function if you already have a file name to which the user may save; for example,
812 * when the user opens an existing file and then does <guimenuitem>File/Save As...</guimenuitem>
813 * on it. If you don't have a file name already — for example, if the user just created
814 * a new file and is saving it for the first time, do not call this function. Instead, use
815 * something similar to this:
818 * if (document_is_new)
820 * /<!-- -->* the user just created a new document *<!-- -->/
821 * gtk_file_chooser_set_current_folder_uri (chooser, default_folder_for_saving);
822 * gtk_file_chooser_set_current_name (chooser, "Untitled document");
826 * /<!-- -->* the user edited an existing document *<!-- -->/
827 * gtk_file_chooser_set_uri (chooser, existing_uri);
831 * Return value: %TRUE if both the folder could be changed and the URI was
832 * selected successfully, %FALSE otherwise.
837 gtk_file_chooser_set_uri (GtkFileChooser *chooser,
840 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
842 gtk_file_chooser_unselect_all (chooser);
843 return gtk_file_chooser_select_uri (chooser, uri);
847 * gtk_file_chooser_select_uri:
848 * @chooser: a #GtkFileChooser
849 * @uri: the URI to select
851 * Selects the file to by @uri. If the URI doesn't refer to a
852 * file in the current folder of @chooser, then the current folder of
853 * @chooser will be changed to the folder containing @filename.
855 * Return value: %TRUE if both the folder could be changed and the URI was
856 * selected successfully, %FALSE otherwise.
861 gtk_file_chooser_select_uri (GtkFileChooser *chooser,
864 GtkFileSystem *file_system;
868 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
869 g_return_val_if_fail (uri != NULL, FALSE);
871 file_system = _gtk_file_chooser_get_file_system (chooser);
873 path = gtk_file_system_uri_to_path (file_system, uri);
876 result = _gtk_file_chooser_select_path (chooser, path, NULL);
877 gtk_file_path_free (path);
886 * gtk_file_chooser_unselect_uri:
887 * @chooser: a #GtkFileChooser
888 * @uri: the URI to unselect
890 * Unselects the file referred to by @uri. If the file
891 * is not in the current directory, does not exist, or
892 * is otherwise not currently selected, does nothing.
897 gtk_file_chooser_unselect_uri (GtkFileChooser *chooser,
900 GtkFileSystem *file_system;
903 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
904 g_return_if_fail (uri != NULL);
906 file_system = _gtk_file_chooser_get_file_system (chooser);
908 path = gtk_file_system_uri_to_path (file_system, uri);
911 _gtk_file_chooser_unselect_path (chooser, path);
912 gtk_file_path_free (path);
917 * gtk_file_chooser_select_all:
918 * @chooser: a #GtkFileChooser
920 * Selects all the files in the current folder of a file chooser.
925 gtk_file_chooser_select_all (GtkFileChooser *chooser)
927 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
929 GTK_FILE_CHOOSER_GET_IFACE (chooser)->select_all (chooser);
933 * gtk_file_chooser_unselect_all:
934 * @chooser: a #GtkFileChooser
936 * Unselects all the files in the current folder of a file chooser.
941 gtk_file_chooser_unselect_all (GtkFileChooser *chooser)
944 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
946 GTK_FILE_CHOOSER_GET_IFACE (chooser)->unselect_all (chooser);
950 * gtk_file_chooser_get_uris:
951 * @chooser: a #GtkFileChooser
953 * Lists all the selected files and subfolders in the current folder of
954 * @chooser. The returned names are full absolute URIs.
956 * Return value: a #GSList containing the URIs of all selected
957 * files and subfolders in the current folder. Free the returned list
958 * with g_slist_free(), and the filenames with g_free().
963 gtk_file_chooser_get_uris (GtkFileChooser *chooser)
965 GtkFileSystem *file_system;
969 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
971 file_system = _gtk_file_chooser_get_file_system (chooser);
972 paths = _gtk_file_chooser_get_paths (chooser);
974 result = file_paths_to_strings (file_system, paths, gtk_file_system_path_to_uri);
975 gtk_file_paths_free (paths);
980 * gtk_file_chooser_set_current_folder_uri:
981 * @chooser: a #GtkFileChooser
982 * @uri: the URI for the new current folder
984 * Sets the current folder for @chooser from an URI.
985 * The user will be shown the full contents of the current folder,
986 * plus user interface elements for navigating to other folders.
988 * Return value: %TRUE if the folder could be changed successfully, %FALSE
994 gtk_file_chooser_set_current_folder_uri (GtkFileChooser *chooser,
997 GtkFileSystem *file_system;
1001 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1002 g_return_val_if_fail (uri != NULL, FALSE);
1004 file_system = _gtk_file_chooser_get_file_system (chooser);
1006 path = gtk_file_system_uri_to_path (file_system, uri);
1009 result = _gtk_file_chooser_set_current_folder_path (chooser, path, NULL);
1010 gtk_file_path_free (path);
1019 * gtk_file_chooser_get_current_folder_uri:
1020 * @chooser: a #GtkFileChooser
1022 * Gets the current folder of @chooser as an URI.
1023 * See gtk_file_chooser_set_current_folder_uri().
1025 * Note that this is the folder that the file chooser is currently displaying
1026 * (e.g. "file:///home/username/Documents"), which is <emphasis>not the same</emphasis>
1027 * as the currently-selected folder if the chooser is in
1028 * #GTK_FILE_CHOOSER_SELECT_FOLDER mode
1029 * (e.g. "file:///home/username/Documents/selected-folder/". To get the
1030 * currently-selected folder in that mode, use gtk_file_chooser_get_uri() as the
1031 * usual way to get the selection.
1033 * Return value: the URI for the current folder. Free with g_free(). This
1034 * function will also return %NULL if the file chooser was unable to load the
1035 * last folder that was requested from it; for example, as would be for calling
1036 * gtk_file_chooser_set_current_folder_uri() on a nonexistent folder.
1041 gtk_file_chooser_get_current_folder_uri (GtkFileChooser *chooser)
1043 GtkFileSystem *file_system;
1047 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1049 file_system = _gtk_file_chooser_get_file_system (chooser);
1051 path = _gtk_file_chooser_get_current_folder_path (chooser);
1052 uri = gtk_file_system_path_to_uri (file_system, path);
1053 gtk_file_path_free (path);
1059 * _gtk_file_chooser_set_current_folder_path:
1060 * @chooser: a #GtkFileChooser
1061 * @path: the #GtkFilePath for the new folder
1062 * @error: location to store error, or %NULL.
1064 * Sets the current folder for @chooser from a #GtkFilePath.
1065 * Internal function, see gtk_file_chooser_set_current_folder_uri().
1067 * Return value: %TRUE if the folder could be changed successfully, %FALSE
1073 _gtk_file_chooser_set_current_folder_path (GtkFileChooser *chooser,
1074 const GtkFilePath *path,
1077 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1078 g_return_val_if_fail (path != NULL, FALSE);
1079 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
1081 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->set_current_folder (chooser, path, error);
1085 * _gtk_file_chooser_get_current_folder_path:
1086 * @chooser: a #GtkFileChooser
1088 * Gets the current folder of @chooser as #GtkFilePath.
1089 * See gtk_file_chooser_get_current_folder_uri().
1091 * Return value: the #GtkFilePath for the current folder.
1092 * Free with gtk_file_path_free().
1097 _gtk_file_chooser_get_current_folder_path (GtkFileChooser *chooser)
1099 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1101 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_current_folder (chooser);
1105 * _gtk_file_chooser_select_path:
1106 * @chooser: a #GtkFileChooser
1107 * @path: the path to select
1108 * @error: location to store error, or %NULL
1110 * Selects the file referred to by @path. An internal function. See
1111 * _gtk_file_chooser_select_uri().
1113 * Return value: %TRUE if both the folder could be changed and the path was
1114 * selected successfully, %FALSE otherwise.
1119 _gtk_file_chooser_select_path (GtkFileChooser *chooser,
1120 const GtkFilePath *path,
1123 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1124 g_return_val_if_fail (path != NULL, FALSE);
1125 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
1127 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->select_path (chooser, path, error);
1131 * _gtk_file_chooser_unselect_path:
1132 * @chooser: a #GtkFileChooser
1133 * @path: the filename to path
1135 * Unselects the file referred to by @path. An internal
1136 * function. See _gtk_file_chooser_unselect_uri().
1141 _gtk_file_chooser_unselect_path (GtkFileChooser *chooser,
1142 const GtkFilePath *path)
1144 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1146 GTK_FILE_CHOOSER_GET_IFACE (chooser)->unselect_path (chooser, path);
1150 * _gtk_file_chooser_get_paths:
1151 * @chooser: a #GtkFileChooser
1153 * Lists all the selected files and subfolders in the current folder of @chooser
1154 * as #GtkFilePath. An internal function, see gtk_file_chooser_get_uris().
1156 * Return value: a #GSList containing a #GtkFilePath for each selected
1157 * file and subfolder in the current folder. Free the returned list
1158 * with g_slist_free(), and the paths with gtk_file_path_free().
1163 _gtk_file_chooser_get_paths (GtkFileChooser *chooser)
1165 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1167 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_paths (chooser);
1170 static GtkFilePath *
1171 gtk_file_chooser_get_path (GtkFileChooser *chooser)
1174 GtkFilePath *result = NULL;
1176 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1178 list = _gtk_file_chooser_get_paths (chooser);
1181 result = list->data;
1182 list = g_slist_delete_link (list, list);
1183 gtk_file_paths_free (list);
1190 * _gtk_file_chooser_get_file_system:
1191 * @chooser: a #GtkFileChooser
1193 * Gets the #GtkFileSystem of @chooser; this is an internal
1194 * implementation detail, used for conversion between paths
1195 * and filenames and URIs.
1197 * Return value: the file system for @chooser.
1202 _gtk_file_chooser_get_file_system (GtkFileChooser *chooser)
1204 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1206 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_file_system (chooser);
1212 * gtk_file_chooser_set_preview_widget:
1213 * @chooser: a #GtkFileChooser
1214 * @preview_widget: widget for displaying preview.
1216 * Sets an application-supplied widget to use to display a custom preview
1217 * of the currently selected file. To implement a preview, after setting the
1218 * preview widget, you connect to the ::update-preview
1219 * signal, and call gtk_file_chooser_get_preview_filename() or
1220 * gtk_file_chooser_get_preview_uri() on each change. If you can
1221 * display a preview of the new file, update your widget and
1222 * set the preview active using gtk_file_chooser_set_preview_widget_active().
1223 * Otherwise, set the preview inactive.
1225 * When there is no application-supplied preview widget, or the
1226 * application-supplied preview widget is not active, the file chooser
1227 * may display an internally generated preview of the current file or
1228 * it may display no preview at all.
1233 gtk_file_chooser_set_preview_widget (GtkFileChooser *chooser,
1234 GtkWidget *preview_widget)
1236 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1238 g_object_set (chooser, "preview-widget", preview_widget, NULL);
1242 * gtk_file_chooser_get_preview_widget:
1243 * @chooser: a #GtkFileChooser
1245 * Gets the current preview widget; see
1246 * gtk_file_chooser_set_preview_widget().
1248 * Return value: the current preview widget, or %NULL
1253 gtk_file_chooser_get_preview_widget (GtkFileChooser *chooser)
1255 GtkWidget *preview_widget;
1257 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1259 g_object_get (chooser, "preview-widget", &preview_widget, NULL);
1261 /* Horrid hack; g_object_get() refs returned objects but
1262 * that contradicts the memory management conventions
1266 g_object_unref (preview_widget);
1268 return preview_widget;
1272 * gtk_file_chooser_set_preview_widget_active:
1273 * @chooser: a #GtkFileChooser
1274 * @active: whether to display the user-specified preview widget
1276 * Sets whether the preview widget set by
1277 * gtk_file_chooser_set_preview_widget() should be shown for the
1278 * current filename. When @active is set to false, the file chooser
1279 * may display an internally generated preview of the current file
1280 * or it may display no preview at all. See
1281 * gtk_file_chooser_set_preview_widget() for more details.
1286 gtk_file_chooser_set_preview_widget_active (GtkFileChooser *chooser,
1289 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1291 g_object_set (chooser, "preview-widget-active", active, NULL);
1295 * gtk_file_chooser_get_preview_widget_active:
1296 * @chooser: a #GtkFileChooser
1298 * Gets whether the preview widget set by gtk_file_chooser_set_preview_widget()
1299 * should be shown for the current filename. See
1300 * gtk_file_chooser_set_preview_widget_active().
1302 * Return value: %TRUE if the preview widget is active for the current filename.
1307 gtk_file_chooser_get_preview_widget_active (GtkFileChooser *chooser)
1311 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1313 g_object_get (chooser, "preview-widget-active", &active, NULL);
1319 * gtk_file_chooser_set_use_preview_label:
1320 * @chooser: a #GtkFileChooser
1321 * @use_label: whether to display a stock label with the name of the previewed file
1323 * Sets whether the file chooser should display a stock label with the name of
1324 * the file that is being previewed; the default is %TRUE. Applications that
1325 * want to draw the whole preview area themselves should set this to %FALSE and
1326 * display the name themselves in their preview widget.
1328 * See also: gtk_file_chooser_set_preview_widget()
1333 gtk_file_chooser_set_use_preview_label (GtkFileChooser *chooser,
1336 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1338 g_object_set (chooser, "use-preview-label", use_label, NULL);
1342 * gtk_file_chooser_get_use_preview_label:
1343 * @chooser: a #GtkFileChooser
1345 * Gets whether a stock label should be drawn with the name of the previewed
1346 * file. See gtk_file_chooser_set_use_preview_label().
1348 * Return value: %TRUE if the file chooser is set to display a label with the
1349 * name of the previewed file, %FALSE otherwise.
1352 gtk_file_chooser_get_use_preview_label (GtkFileChooser *chooser)
1356 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1358 g_object_get (chooser, "use-preview-label", &use_label, NULL);
1364 * gtk_file_chooser_get_preview_filename:
1365 * @chooser: a #GtkFileChooser
1367 * Gets the filename that should be previewed in a custom preview
1368 * Internal function, see gtk_file_chooser_get_preview_uri().
1370 * Return value: the #GtkFilePath for the file to preview, or %NULL if no file
1371 * is selected. Free with gtk_file_path_free().
1376 _gtk_file_chooser_get_preview_path (GtkFileChooser *chooser)
1378 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1380 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_preview_path (chooser);
1384 * _gtk_file_chooser_add_shortcut_folder:
1385 * @chooser: a #GtkFileChooser
1386 * @path: path of the folder to add
1387 * @error: location to store error, or %NULL
1389 * Adds a folder to be displayed with the shortcut folders in a file chooser.
1390 * Internal function, see gtk_file_chooser_add_shortcut_folder().
1392 * Return value: %TRUE if the folder could be added successfully, %FALSE
1398 _gtk_file_chooser_add_shortcut_folder (GtkFileChooser *chooser,
1399 const GtkFilePath *path,
1402 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1403 g_return_val_if_fail (path != NULL, FALSE);
1405 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_shortcut_folder (chooser, path, error);
1409 * _gtk_file_chooser_remove_shortcut_folder:
1410 * @chooser: a #GtkFileChooser
1411 * @path: path of the folder to remove
1412 * @error: location to store error, or %NULL
1414 * Removes a folder from the shortcut folders in a file chooser. Internal
1415 * function, see gtk_file_chooser_remove_shortcut_folder().
1417 * Return value: %TRUE if the folder could be removed successfully, %FALSE
1423 _gtk_file_chooser_remove_shortcut_folder (GtkFileChooser *chooser,
1424 const GtkFilePath *path,
1427 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1428 g_return_val_if_fail (path != NULL, FALSE);
1430 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_shortcut_folder (chooser, path, error);
1434 * gtk_file_chooser_get_preview_filename:
1435 * @chooser: a #GtkFileChooser
1437 * Gets the filename that should be previewed in a custom preview
1438 * widget. See gtk_file_chooser_set_preview_widget().
1440 * Return value: the filename to preview, or %NULL if no file
1441 * is selected, or if the selected file cannot be represented
1442 * as a local filename. Free with g_free()
1447 gtk_file_chooser_get_preview_filename (GtkFileChooser *chooser)
1449 GtkFileSystem *file_system;
1451 gchar *result = NULL;
1453 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1455 file_system = _gtk_file_chooser_get_file_system (chooser);
1456 path = _gtk_file_chooser_get_preview_path (chooser);
1459 result = gtk_file_system_path_to_filename (file_system, path);
1460 gtk_file_path_free (path);
1467 * gtk_file_chooser_get_preview_uri:
1468 * @chooser: a #GtkFileChooser
1470 * Gets the URI that should be previewed in a custom preview
1471 * widget. See gtk_file_chooser_set_preview_widget().
1473 * Return value: the URI for the file to preview, or %NULL if no file is
1474 * selected. Free with g_free().
1479 gtk_file_chooser_get_preview_uri (GtkFileChooser *chooser)
1481 GtkFileSystem *file_system;
1483 gchar *result = NULL;
1485 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1487 file_system = _gtk_file_chooser_get_file_system (chooser);
1488 path = _gtk_file_chooser_get_preview_path (chooser);
1491 result = gtk_file_system_path_to_uri (file_system, path);
1492 gtk_file_path_free (path);
1499 * gtk_file_chooser_set_extra_widget:
1500 * @chooser: a #GtkFileChooser
1501 * @extra_widget: widget for extra options
1503 * Sets an application-supplied widget to provide extra options to the user.
1508 gtk_file_chooser_set_extra_widget (GtkFileChooser *chooser,
1509 GtkWidget *extra_widget)
1511 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1513 g_object_set (chooser, "extra-widget", extra_widget, NULL);
1517 * gtk_file_chooser_get_extra_widget:
1518 * @chooser: a #GtkFileChooser
1520 * Gets the current preview widget; see
1521 * gtk_file_chooser_set_extra_widget().
1523 * Return value: the current extra widget, or %NULL
1528 gtk_file_chooser_get_extra_widget (GtkFileChooser *chooser)
1530 GtkWidget *extra_widget;
1532 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1534 g_object_get (chooser, "extra-widget", &extra_widget, NULL);
1536 /* Horrid hack; g_object_get() refs returned objects but
1537 * that contradicts the memory management conventions
1541 g_object_unref (extra_widget);
1543 return extra_widget;
1547 * gtk_file_chooser_add_filter:
1548 * @chooser: a #GtkFileChooser
1549 * @filter: a #GtkFileFilter
1551 * Adds @filter to the list of filters that the user can select between.
1552 * When a filter is selected, only files that are passed by that
1553 * filter are displayed.
1555 * Note that the @chooser takes ownership of the filter, so you have to
1556 * ref and sink it if you want to keep a reference.
1561 gtk_file_chooser_add_filter (GtkFileChooser *chooser,
1562 GtkFileFilter *filter)
1564 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1566 GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_filter (chooser, filter);
1570 * gtk_file_chooser_remove_filter:
1571 * @chooser: a #GtkFileChooser
1572 * @filter: a #GtkFileFilter
1574 * Removes @filter from the list of filters that the user can select between.
1579 gtk_file_chooser_remove_filter (GtkFileChooser *chooser,
1580 GtkFileFilter *filter)
1582 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1584 GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_filter (chooser, filter);
1588 * gtk_file_chooser_list_filters:
1589 * @chooser: a #GtkFileChooser
1591 * Lists the current set of user-selectable filters; see
1592 * gtk_file_chooser_add_filter(), gtk_file_chooser_remove_filter().
1594 * Return value: a #GSList containing the current set of
1595 * user selectable filters. The contents of the list are
1596 * owned by GTK+, but you must free the list itself with
1597 * g_slist_free() when you are done with it.
1602 gtk_file_chooser_list_filters (GtkFileChooser *chooser)
1604 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1606 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->list_filters (chooser);
1610 * gtk_file_chooser_set_filter:
1611 * @chooser: a #GtkFileChooser
1612 * @filter: a #GtkFileFilter
1614 * Sets the current filter; only the files that pass the
1615 * filter will be displayed. If the user-selectable list of filters
1616 * is non-empty, then the filter should be one of the filters
1617 * in that list. Setting the current filter when the list of
1618 * filters is empty is useful if you want to restrict the displayed
1619 * set of files without letting the user change it.
1624 gtk_file_chooser_set_filter (GtkFileChooser *chooser,
1625 GtkFileFilter *filter)
1627 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1628 g_return_if_fail (GTK_IS_FILE_FILTER (filter));
1630 g_object_set (chooser, "filter", filter, NULL);
1634 * gtk_file_chooser_get_filter:
1635 * @chooser: a #GtkFileChooser
1637 * Gets the current filter; see gtk_file_chooser_set_filter().
1639 * Return value: the current filter, or %NULL
1644 gtk_file_chooser_get_filter (GtkFileChooser *chooser)
1646 GtkFileFilter *filter;
1648 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1650 g_object_get (chooser, "filter", &filter, NULL);
1651 /* Horrid hack; g_object_get() refs returned objects but
1652 * that contradicts the memory management conventions
1656 g_object_unref (filter);
1662 * gtk_file_chooser_add_shortcut_folder:
1663 * @chooser: a #GtkFileChooser
1664 * @folder: filename of the folder to add
1665 * @error: location to store error, or %NULL
1667 * Adds a folder to be displayed with the shortcut folders in a file chooser.
1668 * Note that shortcut folders do not get saved, as they are provided by the
1669 * application. For example, you can use this to add a
1670 * "/usr/share/mydrawprogram/Clipart" folder to the volume list.
1672 * Return value: %TRUE if the folder could be added successfully, %FALSE
1673 * otherwise. In the latter case, the @error will be set as appropriate.
1678 gtk_file_chooser_add_shortcut_folder (GtkFileChooser *chooser,
1685 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1686 g_return_val_if_fail (folder != NULL, FALSE);
1688 path = gtk_file_system_filename_to_path (_gtk_file_chooser_get_file_system (chooser), folder);
1692 GTK_FILE_CHOOSER_ERROR,
1693 GTK_FILE_CHOOSER_ERROR_BAD_FILENAME,
1694 _("Invalid filename: %s"),
1699 result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_shortcut_folder (chooser, path, error);
1701 gtk_file_path_free (path);
1707 * gtk_file_chooser_remove_shortcut_folder:
1708 * @chooser: a #GtkFileChooser
1709 * @folder: filename of the folder to remove
1710 * @error: location to store error, or %NULL
1712 * Removes a folder from a file chooser's list of shortcut folders.
1714 * Return value: %TRUE if the operation succeeds, %FALSE otherwise.
1715 * In the latter case, the @error will be set as appropriate.
1717 * See also: gtk_file_chooser_add_shortcut_folder()
1722 gtk_file_chooser_remove_shortcut_folder (GtkFileChooser *chooser,
1729 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1730 g_return_val_if_fail (folder != NULL, FALSE);
1732 path = gtk_file_system_filename_to_path (_gtk_file_chooser_get_file_system (chooser), folder);
1736 GTK_FILE_CHOOSER_ERROR,
1737 GTK_FILE_CHOOSER_ERROR_BAD_FILENAME,
1738 _("Invalid filename: %s"),
1743 result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_shortcut_folder (chooser, path, error);
1745 gtk_file_path_free (path);
1751 * gtk_file_chooser_list_shortcut_folders:
1752 * @chooser: a #GtkFileChooser
1754 * Queries the list of shortcut folders in the file chooser, as set by
1755 * gtk_file_chooser_add_shortcut_folder().
1757 * Return value: A list of folder filenames, or %NULL if there are no shortcut
1758 * folders. Free the returned list with g_slist_free(), and the filenames with
1764 gtk_file_chooser_list_shortcut_folders (GtkFileChooser *chooser)
1769 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1771 folders = GTK_FILE_CHOOSER_GET_IFACE (chooser)->list_shortcut_folders (chooser);
1773 result = file_paths_to_strings (_gtk_file_chooser_get_file_system (chooser),
1775 gtk_file_system_path_to_filename);
1776 gtk_file_paths_free (folders);
1781 * gtk_file_chooser_add_shortcut_folder_uri:
1782 * @chooser: a #GtkFileChooser
1783 * @uri: URI of the folder to add
1784 * @error: location to store error, or %NULL
1786 * Adds a folder URI to be displayed with the shortcut folders in a file
1787 * chooser. Note that shortcut folders do not get saved, as they are provided
1788 * by the application. For example, you can use this to add a
1789 * "file:///usr/share/mydrawprogram/Clipart" folder to the volume list.
1791 * Return value: %TRUE if the folder could be added successfully, %FALSE
1792 * otherwise. In the latter case, the @error will be set as appropriate.
1797 gtk_file_chooser_add_shortcut_folder_uri (GtkFileChooser *chooser,
1804 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1805 g_return_val_if_fail (uri != NULL, FALSE);
1807 path = gtk_file_system_uri_to_path (_gtk_file_chooser_get_file_system (chooser), uri);
1811 GTK_FILE_CHOOSER_ERROR,
1812 GTK_FILE_CHOOSER_ERROR_BAD_FILENAME,
1813 _("Invalid filename: %s"),
1818 result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_shortcut_folder (chooser, path, error);
1820 gtk_file_path_free (path);
1826 * gtk_file_chooser_remove_shortcut_folder_uri:
1827 * @chooser: a #GtkFileChooser
1828 * @uri: URI of the folder to remove
1829 * @error: location to store error, or %NULL
1831 * Removes a folder URI from a file chooser's list of shortcut folders.
1833 * Return value: %TRUE if the operation succeeds, %FALSE otherwise.
1834 * In the latter case, the @error will be set as appropriate.
1836 * See also: gtk_file_chooser_add_shortcut_folder_uri()
1841 gtk_file_chooser_remove_shortcut_folder_uri (GtkFileChooser *chooser,
1848 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1849 g_return_val_if_fail (uri != NULL, FALSE);
1851 path = gtk_file_system_uri_to_path (_gtk_file_chooser_get_file_system (chooser), uri);
1855 GTK_FILE_CHOOSER_ERROR,
1856 GTK_FILE_CHOOSER_ERROR_BAD_FILENAME,
1857 _("Invalid filename: %s"),
1862 result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_shortcut_folder (chooser, path, error);
1864 gtk_file_path_free (path);
1870 * gtk_file_chooser_list_shortcut_folder_uris:
1871 * @chooser: a #GtkFileChooser
1873 * Queries the list of shortcut folders in the file chooser, as set by
1874 * gtk_file_chooser_add_shortcut_folder_uri().
1876 * Return value: A list of folder URIs, or %NULL if there are no shortcut
1877 * folders. Free the returned list with g_slist_free(), and the URIs with
1883 gtk_file_chooser_list_shortcut_folder_uris (GtkFileChooser *chooser)
1888 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1890 folders = GTK_FILE_CHOOSER_GET_IFACE (chooser)->list_shortcut_folders (chooser);
1892 result = file_paths_to_strings (_gtk_file_chooser_get_file_system (chooser),
1894 gtk_file_system_path_to_uri);
1895 gtk_file_paths_free (folders);
1901 * gtk_file_chooser_set_show_hidden:
1902 * @chooser: a #GtkFileChooser
1903 * @show_hidden: %TRUE if hidden files and folders should be displayed.
1905 * Sets whether hidden files and folders are displayed in the file selector.
1910 gtk_file_chooser_set_show_hidden (GtkFileChooser *chooser,
1911 gboolean show_hidden)
1913 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1915 g_object_set (chooser, "show-hidden", show_hidden, NULL);
1919 * gtk_file_chooser_get_show_hidden:
1920 * @chooser: a #GtkFileChooser
1922 * Gets whether hidden files and folders are displayed in the file selector.
1923 * See gtk_file_chooser_set_show_hidden().
1925 * Return value: %TRUE if hidden files and folders are displayed.
1930 gtk_file_chooser_get_show_hidden (GtkFileChooser *chooser)
1932 gboolean show_hidden;
1934 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1936 g_object_get (chooser, "show-hidden", &show_hidden, NULL);
1942 * gtk_file_chooser_set_do_overwrite_confirmation:
1943 * @chooser: a #GtkFileChooser
1944 * @do_overwrite_confirmation: whether to confirm overwriting in save mode
1946 * Sets whether a file chooser in GTK_FILE_CHOOSER_ACTION_SAVE mode will present
1947 * a confirmation dialog if the user types a file name that already exists. This
1948 * is %FALSE by default.
1950 * Regardless of this setting, the @chooser will emit the "confirm-overwrite"
1951 * signal when appropriate.
1953 * If all you need is the stock confirmation dialog, set this property to %TRUE.
1954 * You can override the way confirmation is done by actually handling the
1955 * "confirm-overwrite" signal; please refer to its documentation for the
1961 gtk_file_chooser_set_do_overwrite_confirmation (GtkFileChooser *chooser,
1962 gboolean do_overwrite_confirmation)
1964 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1966 g_object_set (chooser, "do-overwrite-confirmation", do_overwrite_confirmation, NULL);
1970 * gtk_file_chooser_get_do_overwrite_confirmation:
1971 * @chooser: a #GtkFileChooser
1973 * Queries whether a file chooser is set to confirm for overwriting when the user
1974 * types a file name that already exists.
1976 * Return value: %TRUE if the file chooser will present a confirmation dialog;
1982 gtk_file_chooser_get_do_overwrite_confirmation (GtkFileChooser *chooser)
1984 gboolean do_overwrite_confirmation;
1986 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1988 g_object_get (chooser, "do-overwrite-confirmation", &do_overwrite_confirmation, NULL);
1990 return do_overwrite_confirmation;
1995 /* DLL ABI stability backward compatibility versions */
1997 #undef gtk_file_chooser_get_filename
2000 gtk_file_chooser_get_filename (GtkFileChooser *chooser)
2002 gchar *utf8_filename = gtk_file_chooser_get_filename_utf8 (chooser);
2003 gchar *retval = g_locale_from_utf8 (utf8_filename, -1, NULL, NULL, NULL);
2005 g_free (utf8_filename);
2010 #undef gtk_file_chooser_set_filename
2013 gtk_file_chooser_set_filename (GtkFileChooser *chooser,
2014 const gchar *filename)
2016 gchar *utf8_filename = g_locale_to_utf8 (filename, -1, NULL, NULL, NULL);
2017 gboolean retval = gtk_file_chooser_set_filename_utf8 (chooser, utf8_filename);
2019 g_free (utf8_filename);
2024 #undef gtk_file_chooser_select_filename
2027 gtk_file_chooser_select_filename (GtkFileChooser *chooser,
2028 const gchar *filename)
2030 gchar *utf8_filename = g_locale_to_utf8 (filename, -1, NULL, NULL, NULL);
2031 gboolean retval = gtk_file_chooser_select_filename_utf8 (chooser, utf8_filename);
2033 g_free (utf8_filename);
2038 #undef gtk_file_chooser_unselect_filename
2041 gtk_file_chooser_unselect_filename (GtkFileChooser *chooser,
2042 const char *filename)
2044 gchar *utf8_filename = g_locale_to_utf8 (filename, -1, NULL, NULL, NULL);
2046 gtk_file_chooser_unselect_filename_utf8 (chooser, utf8_filename);
2047 g_free (utf8_filename);
2050 #undef gtk_file_chooser_get_filenames
2053 gtk_file_chooser_get_filenames (GtkFileChooser *chooser)
2055 GSList *list = gtk_file_chooser_get_filenames_utf8 (chooser);
2056 GSList *rover = list;
2060 gchar *tem = (gchar *) rover->data;
2061 rover->data = g_locale_from_utf8 ((gchar *) rover->data, -1, NULL, NULL, NULL);
2063 rover = rover->next;
2069 #undef gtk_file_chooser_set_current_folder
2072 gtk_file_chooser_set_current_folder (GtkFileChooser *chooser,
2073 const gchar *filename)
2075 gchar *utf8_filename = g_locale_to_utf8 (filename, -1, NULL, NULL, NULL);
2076 gboolean retval = gtk_file_chooser_set_current_folder_utf8 (chooser, utf8_filename);
2078 g_free (utf8_filename);
2083 #undef gtk_file_chooser_get_current_folder
2086 gtk_file_chooser_get_current_folder (GtkFileChooser *chooser)
2088 gchar *utf8_folder = gtk_file_chooser_get_current_folder_utf8 (chooser);
2089 gchar *retval = g_locale_from_utf8 (utf8_folder, -1, NULL, NULL, NULL);
2091 g_free (utf8_folder);
2096 #undef gtk_file_chooser_get_preview_filename
2099 gtk_file_chooser_get_preview_filename (GtkFileChooser *chooser)
2101 char *utf8_filename = gtk_file_chooser_get_preview_filename_utf8 (chooser);
2102 char *retval = g_locale_from_utf8 (utf8_filename, -1, NULL, NULL, NULL);
2104 g_free (utf8_filename);
2109 #undef gtk_file_chooser_add_shortcut_folder
2112 gtk_file_chooser_add_shortcut_folder (GtkFileChooser *chooser,
2116 char *utf8_folder = g_locale_to_utf8 (folder, -1, NULL, NULL, NULL);
2118 gtk_file_chooser_add_shortcut_folder_utf8 (chooser, utf8_folder, error);
2120 g_free (utf8_folder);
2125 #undef gtk_file_chooser_remove_shortcut_folder
2128 gtk_file_chooser_remove_shortcut_folder (GtkFileChooser *chooser,
2132 char *utf8_folder = g_locale_to_utf8 (folder, -1, NULL, NULL, NULL);
2134 gtk_file_chooser_remove_shortcut_folder_utf8 (chooser, utf8_folder, error);
2136 g_free (utf8_folder);
2141 #undef gtk_file_chooser_list_shortcut_folders
2144 gtk_file_chooser_list_shortcut_folders (GtkFileChooser *chooser)
2146 GSList *list = gtk_file_chooser_list_shortcut_folders_utf8 (chooser);
2147 GSList *rover = list;
2151 gchar *tem = (gchar *) rover->data;
2152 rover->data = g_locale_from_utf8 ((gchar *) rover->data, -1, NULL, NULL, NULL);
2154 rover = rover->next;
2162 #define __GTK_FILE_CHOOSER_C__
2163 #include "gtkaliasdef.c"