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 static const GTypeInfo file_chooser_info =
44 sizeof (GtkFileChooserIface), /* class_size */
46 NULL, /* base_finalize */
47 (GClassInitFunc)gtk_file_chooser_class_init, /* class_init */
50 file_chooser_type = g_type_register_static (G_TYPE_INTERFACE,
52 &file_chooser_info, 0);
54 g_type_interface_add_prerequisite (file_chooser_type, GTK_TYPE_WIDGET);
57 return file_chooser_type;
61 confirm_overwrite_accumulator (GSignalInvocationHint *ihint,
63 const GValue *handler_return,
66 gboolean continue_emission;
67 GtkFileChooserConfirmation conf;
69 conf = g_value_get_enum (handler_return);
70 g_value_set_enum (return_accu, conf);
71 continue_emission = (conf == GTK_FILE_CHOOSER_CONFIRMATION_CONFIRM);
73 return continue_emission;
77 gtk_file_chooser_class_init (gpointer g_iface)
79 GType iface_type = G_TYPE_FROM_INTERFACE (g_iface);
82 * GtkFileChooser::current-folder-changed
83 * @chooser: the object which received the signal.
85 * This signal is emitted when the current folder in a #GtkFileChooser
86 * changes. This can happen due to the user performing some action that
87 * changes folders, such as selecting a bookmark or visiting a folder on the
88 * file list. It can also happen as a result of calling a function to
89 * explicitly change the current folder in a file chooser.
91 * Normally you do not need to connect to this signal, unless you need to keep
92 * track of which folder a file chooser is showing.
94 * See also: gtk_file_chooser_set_current_folder(),
95 * gtk_file_chooser_get_current_folder(),
96 * gtk_file_chooser_set_current_folder_uri(),
97 * gtk_file_chooser_get_current_folder_uri().
99 g_signal_new ("current-folder-changed",
102 G_STRUCT_OFFSET (GtkFileChooserIface, current_folder_changed),
104 g_cclosure_marshal_VOID__VOID,
108 * GtkFileChooser::selection-changed
109 * @chooser: the object which received the signal.
111 * This signal is emitted when there is a change in the set of selected files
112 * in a #GtkFileChooser. This can happen when the user modifies the selection
113 * with the mouse or the keyboard, or when explicitly calling functions to
114 * change the selection.
116 * Normally you do not need to connect to this signal, as it is easier to wait
117 * for the file chooser to finish running, and then to get the list of
118 * selected files using the functions mentioned below.
120 * See also: gtk_file_chooser_select_filename(),
121 * gtk_file_chooser_unselect_filename(), gtk_file_chooser_get_filename(),
122 * gtk_file_chooser_get_filenames(), gtk_file_chooser_select_uri(),
123 * gtk_file_chooser_unselect_uri(), gtk_file_chooser_get_uri(),
124 * gtk_file_chooser_get_uris().
126 g_signal_new ("selection-changed",
129 G_STRUCT_OFFSET (GtkFileChooserIface, selection_changed),
131 g_cclosure_marshal_VOID__VOID,
135 * GtkFileChooser::update-preview
136 * @chooser: the object which received the signal.
138 * This signal is emitted when the preview in a file chooser should be
139 * regenerated. For example, this can happen when the currently selected file
140 * changes. You should use this signal if you want your file chooser to have
143 * Once you have installed a preview widget with
144 * gtk_file_chooser_set_preview_widget(), you should update it when this
145 * signal is emitted. You can use the functions
146 * gtk_file_chooser_get_preview_filename() or
147 * gtk_file_chooser_get_preview_uri() to get the name of the file to preview.
148 * Your widget may not be able to preview all kinds of files; your callback
149 * must call gtk_file_chooser_set_preview_wiget_active() to inform the file
150 * chooser about whether the preview was generated successfully or not.
152 * Please see the example code in <xref linkend="gtkfilechooser-preview"/>.
154 * See also: gtk_file_chooser_set_preview_widget(),
155 * gtk_file_chooser_set_preview_widget_active(),
156 * gtk_file_chooser_set_use_preview_label(),
157 * gtk_file_chooser_get_preview_filename(),
158 * gtk_file_chooser_get_preview_uri().
160 g_signal_new ("update-preview",
163 G_STRUCT_OFFSET (GtkFileChooserIface, update_preview),
165 g_cclosure_marshal_VOID__VOID,
169 * GtkFileChooser::file-activated
170 * @chooser: the object which received the signal.
172 * This signal is emitted when the user "activates" a file in the file
173 * chooser. This can happen by double-clicking on a file in the file list, or
174 * by pressing <keycap>Enter</keycap>.
176 * Normally you do not need to connect to this signal. It is used internally
177 * by #GtkFileChooserDialog to know when to activate the default button in the
180 * See also: gtk_file_chooser_get_filename(),
181 * gtk_file_chooser_get_filenames(), gtk_file_chooser_get_uri(),
182 * gtk_file_chooser_get_uris().
184 g_signal_new ("file-activated",
187 G_STRUCT_OFFSET (GtkFileChooserIface, file_activated),
189 g_cclosure_marshal_VOID__VOID,
193 * GtkFileChooser::confirm-overwrite
194 * @chooser: the object which received the signal.
198 g_signal_new ("confirm-overwrite",
201 G_STRUCT_OFFSET (GtkFileChooserIface, confirm_overwrite),
202 confirm_overwrite_accumulator, NULL,
203 _gtk_marshal_ENUM__VOID,
204 GTK_TYPE_FILE_CHOOSER_CONFIRMATION, 0);
206 g_object_interface_install_property (g_iface,
207 g_param_spec_enum ("action",
209 P_("The type of operation that the file selector is performing"),
210 GTK_TYPE_FILE_CHOOSER_ACTION,
211 GTK_FILE_CHOOSER_ACTION_OPEN,
212 GTK_PARAM_READWRITE));
213 g_object_interface_install_property (g_iface,
214 g_param_spec_string ("file-system-backend",
215 P_("File System Backend"),
216 P_("Name of file system backend to use"),
218 GTK_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
219 g_object_interface_install_property (g_iface,
220 g_param_spec_object ("filter",
222 P_("The current filter for selecting which files are displayed"),
223 GTK_TYPE_FILE_FILTER,
224 GTK_PARAM_READWRITE));
225 g_object_interface_install_property (g_iface,
226 g_param_spec_boolean ("local-only",
228 P_("Whether the selected file(s) should be limited to local file: URLs"),
230 GTK_PARAM_READWRITE));
231 g_object_interface_install_property (g_iface,
232 g_param_spec_object ("preview-widget",
233 P_("Preview widget"),
234 P_("Application supplied widget for custom previews."),
236 GTK_PARAM_READWRITE));
237 g_object_interface_install_property (g_iface,
238 g_param_spec_boolean ("preview-widget-active",
239 P_("Preview Widget Active"),
240 P_("Whether the application supplied widget for custom previews should be shown."),
242 GTK_PARAM_READWRITE));
243 g_object_interface_install_property (g_iface,
244 g_param_spec_boolean ("use-preview-label",
245 P_("Use Preview Label"),
246 P_("Whether to display a stock label with the name of the previewed file."),
248 GTK_PARAM_READWRITE));
249 g_object_interface_install_property (g_iface,
250 g_param_spec_object ("extra-widget",
252 P_("Application supplied widget for extra options."),
254 GTK_PARAM_READWRITE));
255 g_object_interface_install_property (g_iface,
256 g_param_spec_boolean ("select-multiple",
257 P_("Select Multiple"),
258 P_("Whether to allow multiple files to be selected"),
260 GTK_PARAM_READWRITE));
262 g_object_interface_install_property (g_iface,
263 g_param_spec_boolean ("show-hidden",
265 P_("Whether the hidden files and folders should be displayed"),
267 GTK_PARAM_READWRITE));
269 g_object_interface_install_property (g_iface,
270 g_param_spec_boolean ("do-overwrite-confirmation",
271 P_("Do overwrite confirmation"),
272 P_("Whether a file chooser in GTK_FILE_CHOOSER_ACTION_SAVE "
273 "will present an overwrite confirmation dialog if the user "
274 "selects a file name that already exists."),
276 GTK_PARAM_READWRITE));
280 * gtk_file_chooser_error_quark:
282 * Registers an error quark for #GtkFileChooser if necessary.
284 * Return value: The error quark used for #GtkFileChooser errors.
289 gtk_file_chooser_error_quark (void)
291 static GQuark quark = 0;
293 quark = g_quark_from_static_string ("gtk-file-chooser-error-quark");
298 * gtk_file_chooser_set_action:
299 * @chooser: a #GtkFileChooser
300 * @action: the action that the file selector is performing
302 * Sets the type of operation that the chooser is performing; the
303 * user interface is adapted to suit the selected action. For example,
304 * an option to create a new folder might be shown if the action is
305 * %GTK_FILE_CHOOSER_ACTION_SAVE but not if the action is
306 * %GTK_FILE_CHOOSER_ACTION_OPEN.
311 gtk_file_chooser_set_action (GtkFileChooser *chooser,
312 GtkFileChooserAction action)
314 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
316 g_object_set (chooser, "action", action, NULL);
320 * gtk_file_chooser_get_action:
321 * @chooser: a #GtkFileChooser
323 * Gets the type of operation that the file chooser is performing; see
324 * gtk_file_chooser_set_action().
326 * Return value: the action that the file selector is performing
331 gtk_file_chooser_get_action (GtkFileChooser *chooser)
333 GtkFileChooserAction action;
335 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
337 g_object_get (chooser, "action", &action, NULL);
343 * gtk_file_chooser_set_local_only:
344 * @chooser: a #GtkFileChooser
345 * @local_only: %TRUE if only local files can be selected
347 * Sets whether only local files can be selected in the
348 * file selector. If @local_only is %TRUE (the default),
349 * then the selected file are files are guaranteed to be
350 * accessible through the operating systems native file
351 * file system and therefore the application only
352 * needs to worry about the filename functions in
353 * #GtkFileChooser, like gtk_file_chooser_get_filename(),
354 * rather than the URI functions like
355 * gtk_file_chooser_get_uri(),
360 gtk_file_chooser_set_local_only (GtkFileChooser *chooser,
363 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
365 g_object_set (chooser, "local-only", local_only, NULL);
369 * gtk_file_chooser_get_local_only:
370 * @chooser: a #GtkFileChoosre
372 * Gets whether only local files can be selected in the
373 * file selector. See gtk_file_chooser_set_local_only()
375 * Return value: %TRUE if only local files can be selected.
380 gtk_file_chooser_get_local_only (GtkFileChooser *chooser)
384 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
386 g_object_get (chooser, "local-only", &local_only, NULL);
392 * gtk_file_chooser_set_select_multiple:
393 * @chooser: a #GtkFileChooser
394 * @select_multiple: %TRUE if multiple files can be selected.
396 * Sets whether multiple files can be selected in the file selector. This is
397 * only relevant if the action is set to be GTK_FILE_CHOOSER_ACTION_OPEN or
398 * GTK_FILE_CHOOSER_ACTION_SAVE. It cannot be set with either of the folder
404 gtk_file_chooser_set_select_multiple (GtkFileChooser *chooser,
405 gboolean select_multiple)
407 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
409 g_object_set (chooser, "select-multiple", select_multiple, NULL);
413 * gtk_file_chooser_get_select_multiple:
414 * @chooser: a #GtkFileChooser
416 * Gets whether multiple files can be selected in the file
417 * selector. See gtk_file_chooser_set_select_multiple().
419 * Return value: %TRUE if multiple files can be selected.
424 gtk_file_chooser_get_select_multiple (GtkFileChooser *chooser)
426 gboolean select_multiple;
428 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
430 g_object_get (chooser, "select-multiple", &select_multiple, NULL);
432 return select_multiple;
436 * gtk_file_chooser_get_filename:
437 * @chooser: a #GtkFileChooser
439 * Gets the filename for the currently selected file in
440 * the file selector. If multiple files are selected,
441 * one of the filenames will be returned at random.
443 * If the file chooser is in folder mode, this function returns the selected
446 * Return value: The currently selected filename, or %NULL
447 * if no file is selected, or the selected file can't
448 * be represented with a local filename. Free with g_free().
453 gtk_file_chooser_get_filename (GtkFileChooser *chooser)
455 GtkFileSystem *file_system;
457 gchar *result = NULL;
459 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
461 file_system = _gtk_file_chooser_get_file_system (chooser);
462 path = gtk_file_chooser_get_path (chooser);
465 result = gtk_file_system_path_to_filename (file_system, path);
466 gtk_file_path_free (path);
473 * gtk_file_chooser_set_filename:
474 * @chooser: a #GtkFileChooser
475 * @filename: the filename to set as current
477 * Sets @filename as the current filename for the file chooser;
478 * If the file name isn't in the current folder of @chooser, then the
479 * current folder of @chooser will be changed to the folder containing
480 * @filename. This is equivalent to a sequence of
481 * gtk_file_chooser_unselect_all() followed by gtk_file_chooser_select_filename().
483 * Note that the file must exist, or nothing will be done except
484 * for the directory change. To pre-enter a filename for the user, as in
485 * a save-as dialog, use gtk_file_chooser_set_current_name()
487 * Return value: %TRUE if both the folder could be changed and the file was
488 * selected successfully, %FALSE otherwise.
493 gtk_file_chooser_set_filename (GtkFileChooser *chooser,
494 const gchar *filename)
496 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
498 gtk_file_chooser_unselect_all (chooser);
499 return gtk_file_chooser_select_filename (chooser, filename);
503 * gtk_file_chooser_select_filename:
504 * @chooser: a #GtkFileChooser
505 * @filename: the filename to select
507 * Selects a filename. If the file name isn't in the current
508 * folder of @chooser, then the current folder of @chooser will
509 * be changed to the folder containing @filename.
511 * Return value: %TRUE if both the folder could be changed and the file was
512 * selected successfully, %FALSE otherwise.
517 gtk_file_chooser_select_filename (GtkFileChooser *chooser,
518 const gchar *filename)
520 GtkFileSystem *file_system;
524 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
525 g_return_val_if_fail (filename != NULL, FALSE);
527 file_system = _gtk_file_chooser_get_file_system (chooser);
529 path = gtk_file_system_filename_to_path (file_system, filename);
532 result = _gtk_file_chooser_select_path (chooser, path, NULL);
533 gtk_file_path_free (path);
542 * gtk_file_chooser_unselect_filename:
543 * @chooser: a #GtkFileChooser
544 * @filename: the filename to unselect
546 * Unselects a currently selected filename. If the filename
547 * is not in the current directory, does not exist, or
548 * is otherwise not currently selected, does nothing.
553 gtk_file_chooser_unselect_filename (GtkFileChooser *chooser,
554 const char *filename)
556 GtkFileSystem *file_system;
559 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
560 g_return_if_fail (filename != NULL);
562 file_system = _gtk_file_chooser_get_file_system (chooser);
564 path = gtk_file_system_filename_to_path (file_system, filename);
567 _gtk_file_chooser_unselect_path (chooser, path);
568 gtk_file_path_free (path);
572 /* Converts a list of GtkFilePath* to a list of strings using the specified function */
574 file_paths_to_strings (GtkFileSystem *fs,
576 gchar * (*convert_func) (GtkFileSystem *fs, const GtkFilePath *path))
582 for (; paths; paths = paths->next)
588 string = (* convert_func) (fs, path);
591 strings = g_slist_prepend (strings, string);
594 return g_slist_reverse (strings);
598 * gtk_file_chooser_get_filenames:
599 * @chooser: a #GtkFileChooser
601 * Lists all the selected files and subfolders in the current folder of
602 * @chooser. The returned names are full absolute paths. If files in the current
603 * folder cannot be represented as local filenames they will be ignored. (See
604 * gtk_file_chooser_get_uris())
606 * Return value: a #GSList containing the filenames of all selected
607 * files and subfolders in the current folder. Free the returned list
608 * with g_slist_free(), and the filenames with g_free().
613 gtk_file_chooser_get_filenames (GtkFileChooser *chooser)
615 GtkFileSystem *file_system;
619 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
621 file_system = _gtk_file_chooser_get_file_system (chooser);
622 paths = _gtk_file_chooser_get_paths (chooser);
624 result = file_paths_to_strings (file_system, paths, gtk_file_system_path_to_filename);
625 gtk_file_paths_free (paths);
630 * gtk_file_chooser_set_current_folder:
631 * @chooser: a #GtkFileChooser
632 * @filename: the full path of the new current folder
634 * Sets the current folder for @chooser from a local filename.
635 * The user will be shown the full contents of the current folder,
636 * plus user interface elements for navigating to other folders.
638 * Return value: %TRUE if the folder could be changed successfully, %FALSE
644 gtk_file_chooser_set_current_folder (GtkFileChooser *chooser,
645 const gchar *filename)
647 GtkFileSystem *file_system;
651 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
652 g_return_val_if_fail (filename != NULL, FALSE);
654 file_system = _gtk_file_chooser_get_file_system (chooser);
656 path = gtk_file_system_filename_to_path (file_system, filename);
659 result = _gtk_file_chooser_set_current_folder_path (chooser, path, NULL);
660 gtk_file_path_free (path);
669 * gtk_file_chooser_get_current_folder:
670 * @chooser: a #GtkFileChooser
672 * Gets the current folder of @chooser as a local filename.
673 * See gtk_file_chooser_set_current_folder().
675 * Return value: the full path of the current folder, or %NULL
676 * if the current path cannot be represented as a local filename.
677 * Free with g_free().
682 gtk_file_chooser_get_current_folder (GtkFileChooser *chooser)
684 GtkFileSystem *file_system;
688 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
690 file_system = _gtk_file_chooser_get_file_system (chooser);
692 path = _gtk_file_chooser_get_current_folder_path (chooser);
693 filename = gtk_file_system_path_to_filename (file_system, path);
694 gtk_file_path_free (path);
700 * gtk_file_chooser_set_current_name:
701 * @chooser: a #GtkFileChooser
702 * @name: the filename to use, as a UTF-8 string
704 * Sets the current name in the file selector, as if entered
705 * by the user. Note that the name passed in here is a UTF-8
706 * string rather than a filename. This function is meant for
707 * such uses as a suggested name in a "Save As..." dialog.
709 * If you want to preselect a particular existing file, you
710 * should use gtk_file_chooser_set_filename() instead.
715 gtk_file_chooser_set_current_name (GtkFileChooser *chooser,
718 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
719 g_return_if_fail (name != NULL);
721 GTK_FILE_CHOOSER_GET_IFACE (chooser)->set_current_name (chooser, name);
725 * gtk_file_chooser_get_uri:
726 * @chooser: a #GtkFileChooser
728 * Gets the URI for the currently selected file in
729 * the file selector. If multiple files are selected,
730 * one of the filenames will be returned at random.
732 * If the file chooser is in folder mode, this function returns the selected
735 * Return value: The currently selected URI, or %NULL
736 * if no file is selected. Free with g_free()
741 gtk_file_chooser_get_uri (GtkFileChooser *chooser)
743 GtkFileSystem *file_system;
745 gchar *result = NULL;
747 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
749 file_system = _gtk_file_chooser_get_file_system (chooser);
750 path = gtk_file_chooser_get_path (chooser);
753 result = gtk_file_system_path_to_uri (file_system, path);
754 gtk_file_path_free (path);
761 * gtk_file_chooser_set_uri:
762 * @chooser: a #GtkFileChooser
763 * @uri: the URI to set as current
765 * Sets the file referred to by @uri as the current file for the
766 * file chooser; If the file name isn't in the current folder of @chooser,
767 * then the current folder of @chooser will be changed to the folder containing
768 * @uri. This is equivalent to a sequence of gtk_file_chooser_unselect_all()
769 * followed by gtk_file_chooser_select_uri().
771 * Note that the file must exist, or nothing will be done except
772 * for the directory change. To pre-enter a filename for the user, as in
773 * a save-as dialog, use gtk_file_chooser_set_current_name()
775 * Return value: %TRUE if both the folder could be changed and the URI was
776 * selected successfully, %FALSE otherwise.
781 gtk_file_chooser_set_uri (GtkFileChooser *chooser,
784 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
786 gtk_file_chooser_unselect_all (chooser);
787 return gtk_file_chooser_select_uri (chooser, uri);
791 * gtk_file_chooser_select_uri:
792 * @chooser: a #GtkFileChooser
793 * @uri: the URI to select
795 * Selects the file to by @uri. If the URI doesn't refer to a
796 * file in the current folder of @chooser, then the current folder of
797 * @chooser will be changed to the folder containing @filename.
799 * Return value: %TRUE if both the folder could be changed and the URI was
800 * selected successfully, %FALSE otherwise.
805 gtk_file_chooser_select_uri (GtkFileChooser *chooser,
808 GtkFileSystem *file_system;
812 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
813 g_return_val_if_fail (uri != NULL, FALSE);
815 file_system = _gtk_file_chooser_get_file_system (chooser);
817 path = gtk_file_system_uri_to_path (file_system, uri);
820 result = _gtk_file_chooser_select_path (chooser, path, NULL);
821 gtk_file_path_free (path);
830 * gtk_file_chooser_unselect_uri:
831 * @chooser: a #GtkFileChooser
832 * @uri: the URI to unselect
834 * Unselects the file referred to by @uri. If the file
835 * is not in the current directory, does not exist, or
836 * is otherwise not currently selected, does nothing.
841 gtk_file_chooser_unselect_uri (GtkFileChooser *chooser,
844 GtkFileSystem *file_system;
847 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
848 g_return_if_fail (uri != NULL);
850 file_system = _gtk_file_chooser_get_file_system (chooser);
852 path = gtk_file_system_uri_to_path (file_system, uri);
855 _gtk_file_chooser_unselect_path (chooser, path);
856 gtk_file_path_free (path);
861 * gtk_file_chooser_select_all:
862 * @chooser: a #GtkFileChooser
864 * Selects all the files in the current folder of a file chooser.
869 gtk_file_chooser_select_all (GtkFileChooser *chooser)
871 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
873 GTK_FILE_CHOOSER_GET_IFACE (chooser)->select_all (chooser);
877 * gtk_file_chooser_unselect_all:
878 * @chooser: a #GtkFileChooser
880 * Unselects all the files in the current folder of a file chooser.
885 gtk_file_chooser_unselect_all (GtkFileChooser *chooser)
888 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
890 GTK_FILE_CHOOSER_GET_IFACE (chooser)->unselect_all (chooser);
894 * gtk_file_chooser_get_uris:
895 * @chooser: a #GtkFileChooser
897 * Lists all the selected files and subfolders in the current folder of
898 * @chooser. The returned names are full absolute URIs.
900 * Return value: a #GSList containing the URIs of all selected
901 * files and subfolders in the current folder. Free the returned list
902 * with g_slist_free(), and the filenames with g_free().
907 gtk_file_chooser_get_uris (GtkFileChooser *chooser)
909 GtkFileSystem *file_system;
913 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
915 file_system = _gtk_file_chooser_get_file_system (chooser);
916 paths = _gtk_file_chooser_get_paths (chooser);
918 result = file_paths_to_strings (file_system, paths, gtk_file_system_path_to_uri);
919 gtk_file_paths_free (paths);
924 * gtk_file_chooser_set_current_folder_uri:
925 * @chooser: a #GtkFileChooser
926 * @uri: the URI for the new current folder
928 * Sets the current folder for @chooser from an URI.
929 * The user will be shown the full contents of the current folder,
930 * plus user interface elements for navigating to other folders.
932 * Return value: %TRUE if the folder could be changed successfully, %FALSE
938 gtk_file_chooser_set_current_folder_uri (GtkFileChooser *chooser,
941 GtkFileSystem *file_system;
945 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
946 g_return_val_if_fail (uri != NULL, FALSE);
948 file_system = _gtk_file_chooser_get_file_system (chooser);
950 path = gtk_file_system_uri_to_path (file_system, uri);
953 result = _gtk_file_chooser_set_current_folder_path (chooser, path, NULL);
954 gtk_file_path_free (path);
963 * gtk_file_chooser_get_current_folder_uri:
964 * @chooser: a #GtkFileChooser
966 * Gets the current folder of @chooser as an URI.
967 * See gtk_file_chooser_set_current_folder_uri().
969 * Return value: the URI for the current folder.
970 * Free with g_free().
975 gtk_file_chooser_get_current_folder_uri (GtkFileChooser *chooser)
977 GtkFileSystem *file_system;
981 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
983 file_system = _gtk_file_chooser_get_file_system (chooser);
985 path = _gtk_file_chooser_get_current_folder_path (chooser);
986 uri = gtk_file_system_path_to_uri (file_system, path);
987 gtk_file_path_free (path);
993 * _gtk_file_chooser_set_current_folder_path:
994 * @chooser: a #GtkFileChooser
995 * @path: the #GtkFilePath for the new folder
996 * @error: location to store error, or %NULL.
998 * Sets the current folder for @chooser from a #GtkFilePath.
999 * Internal function, see gtk_file_chooser_set_current_folder_uri().
1001 * Return value: %TRUE if the folder could be changed successfully, %FALSE
1007 _gtk_file_chooser_set_current_folder_path (GtkFileChooser *chooser,
1008 const GtkFilePath *path,
1011 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1012 g_return_val_if_fail (path != NULL, FALSE);
1013 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
1015 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->set_current_folder (chooser, path, error);
1019 * _gtk_file_chooser_get_current_folder_path:
1020 * @chooser: a #GtkFileChooser
1022 * Gets the current folder of @chooser as #GtkFilePath.
1023 * See gtk_file_chooser_get_current_folder_uri().
1025 * Return value: the #GtkFilePath for the current folder.
1026 * Free with gtk_file_path_free().
1031 _gtk_file_chooser_get_current_folder_path (GtkFileChooser *chooser)
1033 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1035 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_current_folder (chooser);
1039 * _gtk_file_chooser_select_path:
1040 * @chooser: a #GtkFileChooser
1041 * @path: the path to select
1042 * @error: location to store error, or %NULL
1044 * Selects the file referred to by @path. An internal function. See
1045 * _gtk_file_chooser_select_uri().
1047 * Return value: %TRUE if both the folder could be changed and the path was
1048 * selected successfully, %FALSE otherwise.
1053 _gtk_file_chooser_select_path (GtkFileChooser *chooser,
1054 const GtkFilePath *path,
1057 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1058 g_return_val_if_fail (path != NULL, FALSE);
1059 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
1061 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->select_path (chooser, path, error);
1065 * _gtk_file_chooser_unselect_path:
1066 * @chooser: a #GtkFileChooser
1067 * @path: the filename to path
1069 * Unselects the file referred to by @path. An internal
1070 * function. See _gtk_file_chooser_unselect_uri().
1075 _gtk_file_chooser_unselect_path (GtkFileChooser *chooser,
1076 const GtkFilePath *path)
1078 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1080 GTK_FILE_CHOOSER_GET_IFACE (chooser)->unselect_path (chooser, path);
1084 * _gtk_file_chooser_get_paths:
1085 * @chooser: a #GtkFileChooser
1087 * Lists all the selected files and subfolders in the current folder of @chooser
1088 * as #GtkFilePath. An internal function, see gtk_file_chooser_get_uris().
1090 * Return value: a #GSList containing a #GtkFilePath for each selected
1091 * file and subfolder in the current folder. Free the returned list
1092 * with g_slist_free(), and the paths with gtk_file_path_free().
1097 _gtk_file_chooser_get_paths (GtkFileChooser *chooser)
1099 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1101 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_paths (chooser);
1104 static GtkFilePath *
1105 gtk_file_chooser_get_path (GtkFileChooser *chooser)
1108 GtkFilePath *result = NULL;
1110 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1112 list = _gtk_file_chooser_get_paths (chooser);
1115 result = list->data;
1116 list = g_slist_delete_link (list, list);
1117 gtk_file_paths_free (list);
1124 * _gtk_file_chooser_get_file_system:
1125 * @chooser: a #GtkFileChooser
1127 * Gets the #GtkFileSystem of @chooser; this is an internal
1128 * implementation detail, used for conversion between paths
1129 * and filenames and URIs.
1131 * Return value: the file system for @chooser.
1136 _gtk_file_chooser_get_file_system (GtkFileChooser *chooser)
1138 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1140 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_file_system (chooser);
1146 * gtk_file_chooser_set_preview_widget:
1147 * @chooser: a #GtkFileChooser
1148 * @preview_widget: widget for displaying preview.
1150 * Sets an application-supplied widget to use to display a custom preview
1151 * of the currently selected file. To implement a preview, after setting the
1152 * preview widget, you connect to the ::update-preview
1153 * signal, and call gtk_file_chooser_get_preview_filename() or
1154 * gtk_file_chooser_get_preview_uri() on each change. If you can
1155 * display a preview of the new file, update your widget and
1156 * set the preview active using gtk_file_chooser_set_preview_widget_active().
1157 * Otherwise, set the preview inactive.
1159 * When there is no application-supplied preview widget, or the
1160 * application-supplied preview widget is not active, the file chooser
1161 * may display an internally generated preview of the current file or
1162 * it may display no preview at all.
1167 gtk_file_chooser_set_preview_widget (GtkFileChooser *chooser,
1168 GtkWidget *preview_widget)
1170 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1172 g_object_set (chooser, "preview-widget", preview_widget, NULL);
1176 * gtk_file_chooser_get_preview_widget:
1177 * @chooser: a #GtkFileChooser
1179 * Gets the current preview widget; see
1180 * gtk_file_chooser_set_preview_widget().
1182 * Return value: the current preview widget, or %NULL
1187 gtk_file_chooser_get_preview_widget (GtkFileChooser *chooser)
1189 GtkWidget *preview_widget;
1191 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1193 g_object_get (chooser, "preview-widget", &preview_widget, NULL);
1195 /* Horrid hack; g_object_get() refs returned objects but
1196 * that contradicts the memory management conventions
1200 g_object_unref (preview_widget);
1202 return preview_widget;
1206 * gtk_file_chooser_set_preview_widget_active:
1207 * @chooser: a #GtkFileChooser
1208 * @active: whether to display the user-specified preview widget
1210 * Sets whether the preview widget set by
1211 * gtk_file_chooser_set_preview_widget() should be shown for the
1212 * current filename. When @active is set to false, the file chooser
1213 * may display an internally generated preview of the current file
1214 * or it may display no preview at all. See
1215 * gtk_file_chooser_set_preview_widget() for more details.
1220 gtk_file_chooser_set_preview_widget_active (GtkFileChooser *chooser,
1223 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1225 g_object_set (chooser, "preview-widget-active", active, NULL);
1229 * gtk_file_chooser_get_preview_widget_active:
1230 * @chooser: a #GtkFileChooser
1232 * Gets whether the preview widget set by gtk_file_chooser_set_preview_widget()
1233 * should be shown for the current filename. See
1234 * gtk_file_chooser_set_preview_widget_active().
1236 * Return value: %TRUE if the preview widget is active for the current filename.
1241 gtk_file_chooser_get_preview_widget_active (GtkFileChooser *chooser)
1245 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1247 g_object_get (chooser, "preview-widget-active", &active, NULL);
1253 * gtk_file_chooser_set_use_preview_label:
1254 * @chooser: a #GtkFileChooser
1255 * @use_label: whether to display a stock label with the name of the previewed file
1257 * Sets whether the file chooser should display a stock label with the name of
1258 * the file that is being previewed; the default is %TRUE. Applications that
1259 * want to draw the whole preview area themselves should set this to %FALSE and
1260 * display the name themselves in their preview widget.
1262 * See also: gtk_file_chooser_set_preview_widget()
1267 gtk_file_chooser_set_use_preview_label (GtkFileChooser *chooser,
1270 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1272 g_object_set (chooser, "use-preview-label", use_label, NULL);
1276 * gtk_file_chooser_get_use_preview_label:
1277 * @chooser: a #GtkFileChooser
1279 * Gets whether a stock label should be drawn with the name of the previewed
1280 * file. See gtk_file_chooser_set_use_preview_label().
1282 * Return value: %TRUE if the file chooser is set to display a label with the
1283 * name of the previewed file, %FALSE otherwise.
1286 gtk_file_chooser_get_use_preview_label (GtkFileChooser *chooser)
1290 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1292 g_object_get (chooser, "use-preview-label", &use_label, NULL);
1298 * gtk_file_chooser_get_preview_filename:
1299 * @chooser: a #GtkFileChooser
1301 * Gets the filename that should be previewed in a custom preview
1302 * Internal function, see gtk_file_chooser_get_preview_uri().
1304 * Return value: the #GtkFilePath for the file to preview, or %NULL if no file
1305 * is selected. Free with gtk_file_path_free().
1310 _gtk_file_chooser_get_preview_path (GtkFileChooser *chooser)
1312 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1314 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_preview_path (chooser);
1318 * _gtk_file_chooser_add_shortcut_folder:
1319 * @chooser: a #GtkFileChooser
1320 * @path: path of the folder to add
1321 * @error: location to store error, or %NULL
1323 * Adds a folder to be displayed with the shortcut folders in a file chooser.
1324 * Internal function, see gtk_file_chooser_add_shortcut_folder().
1326 * Return value: %TRUE if the folder could be added successfully, %FALSE
1332 _gtk_file_chooser_add_shortcut_folder (GtkFileChooser *chooser,
1333 const GtkFilePath *path,
1336 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1337 g_return_val_if_fail (path != NULL, FALSE);
1339 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_shortcut_folder (chooser, path, error);
1343 * _gtk_file_chooser_remove_shortcut_folder:
1344 * @chooser: a #GtkFileChooser
1345 * @path: path of the folder to remove
1346 * @error: location to store error, or %NULL
1348 * Removes a folder from the shortcut folders in a file chooser. Internal
1349 * function, see gtk_file_chooser_remove_shortcut_folder().
1351 * Return value: %TRUE if the folder could be removed successfully, %FALSE
1357 _gtk_file_chooser_remove_shortcut_folder (GtkFileChooser *chooser,
1358 const GtkFilePath *path,
1361 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1362 g_return_val_if_fail (path != NULL, FALSE);
1364 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_shortcut_folder (chooser, path, error);
1368 * gtk_file_chooser_get_preview_filename:
1369 * @chooser: a #GtkFileChooser
1371 * Gets the filename that should be previewed in a custom preview
1372 * widget. See gtk_file_chooser_set_preview_widget().
1374 * Return value: the filename to preview, or %NULL if no file
1375 * is selected, or if the selected file cannot be represented
1376 * as a local filename. Free with g_free()
1381 gtk_file_chooser_get_preview_filename (GtkFileChooser *chooser)
1383 GtkFileSystem *file_system;
1385 gchar *result = NULL;
1387 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1389 file_system = _gtk_file_chooser_get_file_system (chooser);
1390 path = _gtk_file_chooser_get_preview_path (chooser);
1393 result = gtk_file_system_path_to_filename (file_system, path);
1394 gtk_file_path_free (path);
1401 * gtk_file_chooser_get_preview_uri:
1402 * @chooser: a #GtkFileChooser
1404 * Gets the URI that should be previewed in a custom preview
1405 * widget. See gtk_file_chooser_set_preview_widget().
1407 * Return value: the URI for the file to preview, or %NULL if no file is
1408 * selected. Free with g_free().
1413 gtk_file_chooser_get_preview_uri (GtkFileChooser *chooser)
1415 GtkFileSystem *file_system;
1417 gchar *result = NULL;
1419 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1421 file_system = _gtk_file_chooser_get_file_system (chooser);
1422 path = _gtk_file_chooser_get_preview_path (chooser);
1425 result = gtk_file_system_path_to_uri (file_system, path);
1426 gtk_file_path_free (path);
1433 * gtk_file_chooser_set_extra_widget:
1434 * @chooser: a #GtkFileChooser
1435 * @extra_widget: widget for extra options
1437 * Sets an application-supplied widget to provide extra options to the user.
1442 gtk_file_chooser_set_extra_widget (GtkFileChooser *chooser,
1443 GtkWidget *extra_widget)
1445 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1447 g_object_set (chooser, "extra-widget", extra_widget, NULL);
1451 * gtk_file_chooser_get_extra_widget:
1452 * @chooser: a #GtkFileChooser
1454 * Gets the current preview widget; see
1455 * gtk_file_chooser_set_extra_widget().
1457 * Return value: the current extra widget, or %NULL
1462 gtk_file_chooser_get_extra_widget (GtkFileChooser *chooser)
1464 GtkWidget *extra_widget;
1466 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1468 g_object_get (chooser, "extra-widget", &extra_widget, NULL);
1470 /* Horrid hack; g_object_get() refs returned objects but
1471 * that contradicts the memory management conventions
1475 g_object_unref (extra_widget);
1477 return extra_widget;
1481 * gtk_file_chooser_add_filter:
1482 * @chooser: a #GtkFileChooser
1483 * @filter: a #GtkFileFilter
1485 * Adds @filter to the list of filters that the user can select between.
1486 * When a filter is selected, only files that are passed by that
1487 * filter are displayed.
1489 * Note that the @chooser takes ownership of the filter, so you have to
1490 * ref and sink it if you want to keep a reference.
1495 gtk_file_chooser_add_filter (GtkFileChooser *chooser,
1496 GtkFileFilter *filter)
1498 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1500 GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_filter (chooser, filter);
1504 * gtk_file_chooser_remove_filter:
1505 * @chooser: a #GtkFileChooser
1506 * @filter: a #GtkFileFilter
1508 * Removes @filter from the list of filters that the user can select between.
1513 gtk_file_chooser_remove_filter (GtkFileChooser *chooser,
1514 GtkFileFilter *filter)
1516 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1518 GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_filter (chooser, filter);
1522 * gtk_file_chooser_list_filters:
1523 * @chooser: a #GtkFileChooser
1525 * Lists the current set of user-selectable filters; see
1526 * gtk_file_chooser_add_filter(), gtk_file_chooser_remove_filter().
1528 * Return value: a #GSList containing the current set of
1529 * user selectable filters. The contents of the list are
1530 * owned by GTK+, but you must free the list itself with
1531 * g_slist_free() when you are done with it.
1536 gtk_file_chooser_list_filters (GtkFileChooser *chooser)
1538 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1540 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->list_filters (chooser);
1544 * gtk_file_chooser_set_filter:
1545 * @chooser: a #GtkFileChooser
1546 * @filter: a #GtkFileFilter
1548 * Sets the current filter; only the files that pass the
1549 * filter will be displayed. If the user-selectable list of filters
1550 * is non-empty, then the filter should be one of the filters
1551 * in that list. Setting the current filter when the list of
1552 * filters is empty is useful if you want to restrict the displayed
1553 * set of files without letting the user change it.
1558 gtk_file_chooser_set_filter (GtkFileChooser *chooser,
1559 GtkFileFilter *filter)
1561 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1562 g_return_if_fail (GTK_IS_FILE_FILTER (filter));
1564 g_object_set (chooser, "filter", filter, NULL);
1568 * gtk_file_chooser_get_filter:
1569 * @chooser: a #GtkFileChooser
1571 * Gets the current filter; see gtk_file_chooser_set_filter().
1573 * Return value: the current filter, or %NULL
1578 gtk_file_chooser_get_filter (GtkFileChooser *chooser)
1580 GtkFileFilter *filter;
1582 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1584 g_object_get (chooser, "filter", &filter, NULL);
1585 /* Horrid hack; g_object_get() refs returned objects but
1586 * that contradicts the memory management conventions
1590 g_object_unref (filter);
1596 * gtk_file_chooser_add_shortcut_folder:
1597 * @chooser: a #GtkFileChooser
1598 * @folder: filename of the folder to add
1599 * @error: location to store error, or %NULL
1601 * Adds a folder to be displayed with the shortcut folders in a file chooser.
1602 * Note that shortcut folders do not get saved, as they are provided by the
1603 * application. For example, you can use this to add a
1604 * "/usr/share/mydrawprogram/Clipart" folder to the volume list.
1606 * Return value: %TRUE if the folder could be added successfully, %FALSE
1607 * otherwise. In the latter case, the @error will be set as appropriate.
1612 gtk_file_chooser_add_shortcut_folder (GtkFileChooser *chooser,
1619 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1620 g_return_val_if_fail (folder != NULL, FALSE);
1622 path = gtk_file_system_filename_to_path (_gtk_file_chooser_get_file_system (chooser), folder);
1626 GTK_FILE_CHOOSER_ERROR,
1627 GTK_FILE_CHOOSER_ERROR_BAD_FILENAME,
1628 _("Invalid filename: %s"),
1633 result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_shortcut_folder (chooser, path, error);
1635 gtk_file_path_free (path);
1641 * gtk_file_chooser_remove_shortcut_folder:
1642 * @chooser: a #GtkFileChooser
1643 * @folder: filename of the folder to remove
1644 * @error: location to store error, or %NULL
1646 * Removes a folder from a file chooser's list of shortcut folders.
1648 * Return value: %TRUE if the operation succeeds, %FALSE otherwise.
1649 * In the latter case, the @error will be set as appropriate.
1651 * See also: gtk_file_chooser_add_shortcut_folder()
1656 gtk_file_chooser_remove_shortcut_folder (GtkFileChooser *chooser,
1663 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1664 g_return_val_if_fail (folder != NULL, FALSE);
1666 path = gtk_file_system_filename_to_path (_gtk_file_chooser_get_file_system (chooser), folder);
1670 GTK_FILE_CHOOSER_ERROR,
1671 GTK_FILE_CHOOSER_ERROR_BAD_FILENAME,
1672 _("Invalid filename: %s"),
1677 result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_shortcut_folder (chooser, path, error);
1679 gtk_file_path_free (path);
1685 * gtk_file_chooser_list_shortcut_folders:
1686 * @chooser: a #GtkFileChooser
1688 * Queries the list of shortcut folders in the file chooser, as set by
1689 * gtk_file_chooser_add_shortcut_folder().
1691 * Return value: A list of folder filenames, or %NULL if there are no shortcut
1692 * folders. Free the returned list with g_slist_free(), and the filenames with
1698 gtk_file_chooser_list_shortcut_folders (GtkFileChooser *chooser)
1703 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1705 folders = GTK_FILE_CHOOSER_GET_IFACE (chooser)->list_shortcut_folders (chooser);
1707 result = file_paths_to_strings (_gtk_file_chooser_get_file_system (chooser),
1709 gtk_file_system_path_to_filename);
1710 gtk_file_paths_free (folders);
1715 * gtk_file_chooser_add_shortcut_folder_uri:
1716 * @chooser: a #GtkFileChooser
1717 * @uri: URI of the folder to add
1718 * @error: location to store error, or %NULL
1720 * Adds a folder URI to be displayed with the shortcut folders in a file
1721 * chooser. Note that shortcut folders do not get saved, as they are provided
1722 * by the application. For example, you can use this to add a
1723 * "file:///usr/share/mydrawprogram/Clipart" folder to the volume list.
1725 * Return value: %TRUE if the folder could be added successfully, %FALSE
1726 * otherwise. In the latter case, the @error will be set as appropriate.
1731 gtk_file_chooser_add_shortcut_folder_uri (GtkFileChooser *chooser,
1738 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1739 g_return_val_if_fail (uri != NULL, FALSE);
1741 path = gtk_file_system_uri_to_path (_gtk_file_chooser_get_file_system (chooser), uri);
1745 GTK_FILE_CHOOSER_ERROR,
1746 GTK_FILE_CHOOSER_ERROR_BAD_FILENAME,
1747 _("Invalid filename: %s"),
1752 result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_shortcut_folder (chooser, path, error);
1754 gtk_file_path_free (path);
1760 * gtk_file_chooser_remove_shortcut_folder_uri:
1761 * @chooser: a #GtkFileChooser
1762 * @uri: URI of the folder to remove
1763 * @error: location to store error, or %NULL
1765 * Removes a folder URI from a file chooser's list of shortcut folders.
1767 * Return value: %TRUE if the operation succeeds, %FALSE otherwise.
1768 * In the latter case, the @error will be set as appropriate.
1770 * See also: gtk_file_chooser_add_shortcut_folder_uri()
1775 gtk_file_chooser_remove_shortcut_folder_uri (GtkFileChooser *chooser,
1782 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1783 g_return_val_if_fail (uri != NULL, FALSE);
1785 path = gtk_file_system_uri_to_path (_gtk_file_chooser_get_file_system (chooser), uri);
1789 GTK_FILE_CHOOSER_ERROR,
1790 GTK_FILE_CHOOSER_ERROR_BAD_FILENAME,
1791 _("Invalid filename: %s"),
1796 result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_shortcut_folder (chooser, path, error);
1798 gtk_file_path_free (path);
1804 * gtk_file_chooser_list_shortcut_folder_uris:
1805 * @chooser: a #GtkFileChooser
1807 * Queries the list of shortcut folders in the file chooser, as set by
1808 * gtk_file_chooser_add_shortcut_folder_uri().
1810 * Return value: A list of folder URIs, or %NULL if there are no shortcut
1811 * folders. Free the returned list with g_slist_free(), and the URIs with
1817 gtk_file_chooser_list_shortcut_folder_uris (GtkFileChooser *chooser)
1822 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1824 folders = GTK_FILE_CHOOSER_GET_IFACE (chooser)->list_shortcut_folders (chooser);
1826 result = file_paths_to_strings (_gtk_file_chooser_get_file_system (chooser),
1828 gtk_file_system_path_to_uri);
1829 gtk_file_paths_free (folders);
1835 * gtk_file_chooser_set_show_hidden:
1836 * @chooser: a #GtkFileChooser
1837 * @show_hidden: %TRUE if hidden files and folders should be displayed.
1839 * Sets whether hidden files and folders are displayed in the file selector.
1844 gtk_file_chooser_set_show_hidden (GtkFileChooser *chooser,
1845 gboolean show_hidden)
1847 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1849 g_object_set (chooser, "show-hidden", show_hidden, NULL);
1853 * gtk_file_chooser_get_show_hidden:
1854 * @chooser: a #GtkFileChooser
1856 * Gets whether hidden files and folders are displayed in the file selector.
1857 * See gtk_file_chooser_set_show_hidden().
1859 * Return value: %TRUE if hidden files and folders are displayed.
1864 gtk_file_chooser_get_show_hidden (GtkFileChooser *chooser)
1866 gboolean show_hidden;
1868 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1870 g_object_get (chooser, "show-hidden", &show_hidden, NULL);
1876 * gtk_file_chooser_set_do_overwrite_confirmation:
1877 * @chooser: a #GtkFileChooser
1878 * @do_overwrite_confirmation: whether to confirm overwriting in save mode
1880 * Sets whether a file chooser in GTK_FILE_CHOOSER_ACTION_SAVE mode will present
1881 * a confirmation dialog if the user types a file name that already exists. This
1882 * is %FALSE by default.
1884 * Regardless of this setting, the @chooser will emit the "confirm-overwrite"
1885 * signal when appropriate.
1887 * If all you need is the stock confirmation dialog, set this property to %TRUE.
1888 * You can override the way confirmation is done by actually handling the
1889 * "confirm-overwrite" signal; please refer to its documentation for the
1893 gtk_file_chooser_set_do_overwrite_confirmation (GtkFileChooser *chooser,
1894 gboolean do_overwrite_confirmation)
1896 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1898 g_object_set (chooser, "do-overwrite-confirmation", do_overwrite_confirmation, NULL);
1902 * gtk_file_chooser_get_do_overwrite_confirmation:
1903 * @chooser: a #GtkFileChooser
1905 * Queries whether a file chooser is set to confirm for overwriting when the user
1906 * types a file name that already exists.
1908 * Return value: %TRUE if the file chooser will present a confirmation dialog;
1912 gtk_file_chooser_get_do_overwrite_confirmation (GtkFileChooser *chooser)
1914 gboolean do_overwrite_confirmation;
1916 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1918 g_object_get (chooser, "do-overwrite-confirmation", &do_overwrite_confirmation, NULL);
1920 return do_overwrite_confirmation;
1925 /* DLL ABI stability backward compatibility versions */
1927 #undef gtk_file_chooser_get_filename
1930 gtk_file_chooser_get_filename (GtkFileChooser *chooser)
1932 gchar *utf8_filename = gtk_file_chooser_get_filename_utf8 (chooser);
1933 gchar *retval = g_locale_from_utf8 (utf8_filename, -1, NULL, NULL, NULL);
1935 g_free (utf8_filename);
1940 #undef gtk_file_chooser_set_filename
1943 gtk_file_chooser_set_filename (GtkFileChooser *chooser,
1944 const gchar *filename)
1946 gchar *utf8_filename = g_locale_to_utf8 (filename, -1, NULL, NULL, NULL);
1947 gboolean retval = gtk_file_chooser_set_filename_utf8 (chooser, utf8_filename);
1949 g_free (utf8_filename);
1954 #undef gtk_file_chooser_select_filename
1957 gtk_file_chooser_select_filename (GtkFileChooser *chooser,
1958 const gchar *filename)
1960 gchar *utf8_filename = g_locale_to_utf8 (filename, -1, NULL, NULL, NULL);
1961 gboolean retval = gtk_file_chooser_select_filename_utf8 (chooser, utf8_filename);
1963 g_free (utf8_filename);
1968 #undef gtk_file_chooser_unselect_filename
1971 gtk_file_chooser_unselect_filename (GtkFileChooser *chooser,
1972 const char *filename)
1974 gchar *utf8_filename = g_locale_to_utf8 (filename, -1, NULL, NULL, NULL);
1976 gtk_file_chooser_unselect_filename_utf8 (chooser, utf8_filename);
1977 g_free (utf8_filename);
1980 #undef gtk_file_chooser_get_filenames
1983 gtk_file_chooser_get_filenames (GtkFileChooser *chooser)
1985 GSList *list = gtk_file_chooser_get_filenames_utf8 (chooser);
1986 GSList *rover = list;
1990 gchar *tem = (gchar *) rover->data;
1991 rover->data = g_locale_from_utf8 ((gchar *) rover->data, -1, NULL, NULL, NULL);
1993 rover = rover->next;
1999 #undef gtk_file_chooser_set_current_folder
2002 gtk_file_chooser_set_current_folder (GtkFileChooser *chooser,
2003 const gchar *filename)
2005 gchar *utf8_filename = g_locale_to_utf8 (filename, -1, NULL, NULL, NULL);
2006 gboolean retval = gtk_file_chooser_set_current_folder_utf8 (chooser, utf8_filename);
2008 g_free (utf8_filename);
2013 #undef gtk_file_chooser_get_current_folder
2016 gtk_file_chooser_get_current_folder (GtkFileChooser *chooser)
2018 gchar *utf8_folder = gtk_file_chooser_get_current_folder_utf8 (chooser);
2019 gchar *retval = g_locale_from_utf8 (utf8_folder, -1, NULL, NULL, NULL);
2021 g_free (utf8_folder);
2026 #undef gtk_file_chooser_get_preview_filename
2029 gtk_file_chooser_get_preview_filename (GtkFileChooser *chooser)
2031 char *utf8_filename = gtk_file_chooser_get_preview_filename_utf8 (chooser);
2032 char *retval = g_locale_from_utf8 (utf8_filename, -1, NULL, NULL, NULL);
2034 g_free (utf8_filename);
2039 #undef gtk_file_chooser_add_shortcut_folder
2042 gtk_file_chooser_add_shortcut_folder (GtkFileChooser *chooser,
2046 char *utf8_folder = g_locale_to_utf8 (folder, -1, NULL, NULL, NULL);
2048 gtk_file_chooser_add_shortcut_folder_utf8 (chooser, utf8_folder, error);
2050 g_free (utf8_folder);
2055 #undef gtk_file_chooser_remove_shortcut_folder
2058 gtk_file_chooser_remove_shortcut_folder (GtkFileChooser *chooser,
2062 char *utf8_folder = g_locale_to_utf8 (folder, -1, NULL, NULL, NULL);
2064 gtk_file_chooser_remove_shortcut_folder_utf8 (chooser, utf8_folder, error);
2066 g_free (utf8_folder);
2071 #undef gtk_file_chooser_list_shortcut_folders
2074 gtk_file_chooser_list_shortcut_folders (GtkFileChooser *chooser)
2076 GSList *list = gtk_file_chooser_list_shortcut_folders_utf8 (chooser);
2077 GSList *rover = list;
2081 gchar *tem = (gchar *) rover->data;
2082 rover->data = g_locale_from_utf8 ((gchar *) rover->data, -1, NULL, NULL, NULL);
2084 rover = rover->next;
2092 #define __GTK_FILE_CHOOSER_C__
2093 #include "gtkaliasdef.c"