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,
192 /* Documented in the docbook files */
193 g_signal_new ("confirm-overwrite",
196 G_STRUCT_OFFSET (GtkFileChooserIface, confirm_overwrite),
197 confirm_overwrite_accumulator, NULL,
198 _gtk_marshal_ENUM__VOID,
199 GTK_TYPE_FILE_CHOOSER_CONFIRMATION, 0);
201 g_object_interface_install_property (g_iface,
202 g_param_spec_enum ("action",
204 P_("The type of operation that the file selector is performing"),
205 GTK_TYPE_FILE_CHOOSER_ACTION,
206 GTK_FILE_CHOOSER_ACTION_OPEN,
207 GTK_PARAM_READWRITE));
208 g_object_interface_install_property (g_iface,
209 g_param_spec_string ("file-system-backend",
210 P_("File System Backend"),
211 P_("Name of file system backend to use"),
213 GTK_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
214 g_object_interface_install_property (g_iface,
215 g_param_spec_object ("filter",
217 P_("The current filter for selecting which files are displayed"),
218 GTK_TYPE_FILE_FILTER,
219 GTK_PARAM_READWRITE));
220 g_object_interface_install_property (g_iface,
221 g_param_spec_boolean ("local-only",
223 P_("Whether the selected file(s) should be limited to local file: URLs"),
225 GTK_PARAM_READWRITE));
226 g_object_interface_install_property (g_iface,
227 g_param_spec_object ("preview-widget",
228 P_("Preview widget"),
229 P_("Application supplied widget for custom previews."),
231 GTK_PARAM_READWRITE));
232 g_object_interface_install_property (g_iface,
233 g_param_spec_boolean ("preview-widget-active",
234 P_("Preview Widget Active"),
235 P_("Whether the application supplied widget for custom previews should be shown."),
237 GTK_PARAM_READWRITE));
238 g_object_interface_install_property (g_iface,
239 g_param_spec_boolean ("use-preview-label",
240 P_("Use Preview Label"),
241 P_("Whether to display a stock label with the name of the previewed file."),
243 GTK_PARAM_READWRITE));
244 g_object_interface_install_property (g_iface,
245 g_param_spec_object ("extra-widget",
247 P_("Application supplied widget for extra options."),
249 GTK_PARAM_READWRITE));
250 g_object_interface_install_property (g_iface,
251 g_param_spec_boolean ("select-multiple",
252 P_("Select Multiple"),
253 P_("Whether to allow multiple files to be selected"),
255 GTK_PARAM_READWRITE));
257 g_object_interface_install_property (g_iface,
258 g_param_spec_boolean ("show-hidden",
260 P_("Whether the hidden files and folders should be displayed"),
262 GTK_PARAM_READWRITE));
264 g_object_interface_install_property (g_iface,
265 g_param_spec_boolean ("do-overwrite-confirmation",
266 P_("Do overwrite confirmation"),
267 P_("Whether a file chooser in GTK_FILE_CHOOSER_ACTION_SAVE "
268 "will present an overwrite confirmation dialog if the user "
269 "selects a file name that already exists."),
271 GTK_PARAM_READWRITE));
275 * gtk_file_chooser_error_quark:
277 * Registers an error quark for #GtkFileChooser if necessary.
279 * Return value: The error quark used for #GtkFileChooser errors.
284 gtk_file_chooser_error_quark (void)
286 static GQuark quark = 0;
288 quark = 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_SAVE. It cannot be set with either of the folder
399 gtk_file_chooser_set_select_multiple (GtkFileChooser *chooser,
400 gboolean select_multiple)
402 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
404 g_object_set (chooser, "select-multiple", select_multiple, NULL);
408 * gtk_file_chooser_get_select_multiple:
409 * @chooser: a #GtkFileChooser
411 * Gets whether multiple files can be selected in the file
412 * selector. See gtk_file_chooser_set_select_multiple().
414 * Return value: %TRUE if multiple files can be selected.
419 gtk_file_chooser_get_select_multiple (GtkFileChooser *chooser)
421 gboolean select_multiple;
423 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
425 g_object_get (chooser, "select-multiple", &select_multiple, NULL);
427 return select_multiple;
431 * gtk_file_chooser_get_filename:
432 * @chooser: a #GtkFileChooser
434 * Gets the filename for the currently selected file in
435 * the file selector. If multiple files are selected,
436 * one of the filenames will be returned at random.
438 * If the file chooser is in folder mode, this function returns the selected
441 * Return value: The currently selected filename, or %NULL
442 * if no file is selected, or the selected file can't
443 * be represented with a local filename. Free with g_free().
448 gtk_file_chooser_get_filename (GtkFileChooser *chooser)
450 GtkFileSystem *file_system;
452 gchar *result = NULL;
454 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
456 file_system = _gtk_file_chooser_get_file_system (chooser);
457 path = gtk_file_chooser_get_path (chooser);
460 result = gtk_file_system_path_to_filename (file_system, path);
461 gtk_file_path_free (path);
468 * gtk_file_chooser_set_filename:
469 * @chooser: a #GtkFileChooser
470 * @filename: the filename to set as current
472 * Sets @filename as the current filename for the file chooser;
473 * If the file name isn't in the current folder of @chooser, then the
474 * current folder of @chooser will be changed to the folder containing
475 * @filename. This is equivalent to a sequence of
476 * gtk_file_chooser_unselect_all() followed by gtk_file_chooser_select_filename().
478 * Note that the file must exist, or nothing will be done except
479 * for the directory change. To pre-enter a filename for the user, as in
480 * a save-as dialog, use gtk_file_chooser_set_current_name()
482 * Return value: %TRUE if both the folder could be changed and the file was
483 * selected successfully, %FALSE otherwise.
488 gtk_file_chooser_set_filename (GtkFileChooser *chooser,
489 const gchar *filename)
491 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
493 gtk_file_chooser_unselect_all (chooser);
494 return gtk_file_chooser_select_filename (chooser, filename);
498 * gtk_file_chooser_select_filename:
499 * @chooser: a #GtkFileChooser
500 * @filename: the filename to select
502 * Selects a filename. If the file name isn't in the current
503 * folder of @chooser, then the current folder of @chooser will
504 * be changed to the folder containing @filename.
506 * Return value: %TRUE if both the folder could be changed and the file was
507 * selected successfully, %FALSE otherwise.
512 gtk_file_chooser_select_filename (GtkFileChooser *chooser,
513 const gchar *filename)
515 GtkFileSystem *file_system;
519 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
520 g_return_val_if_fail (filename != NULL, FALSE);
522 file_system = _gtk_file_chooser_get_file_system (chooser);
524 path = gtk_file_system_filename_to_path (file_system, filename);
527 result = _gtk_file_chooser_select_path (chooser, path, NULL);
528 gtk_file_path_free (path);
537 * gtk_file_chooser_unselect_filename:
538 * @chooser: a #GtkFileChooser
539 * @filename: the filename to unselect
541 * Unselects a currently selected filename. If the filename
542 * is not in the current directory, does not exist, or
543 * is otherwise not currently selected, does nothing.
548 gtk_file_chooser_unselect_filename (GtkFileChooser *chooser,
549 const char *filename)
551 GtkFileSystem *file_system;
554 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
555 g_return_if_fail (filename != NULL);
557 file_system = _gtk_file_chooser_get_file_system (chooser);
559 path = gtk_file_system_filename_to_path (file_system, filename);
562 _gtk_file_chooser_unselect_path (chooser, path);
563 gtk_file_path_free (path);
567 /* Converts a list of GtkFilePath* to a list of strings using the specified function */
569 file_paths_to_strings (GtkFileSystem *fs,
571 gchar * (*convert_func) (GtkFileSystem *fs, const GtkFilePath *path))
577 for (; paths; paths = paths->next)
583 string = (* convert_func) (fs, path);
586 strings = g_slist_prepend (strings, string);
589 return g_slist_reverse (strings);
593 * gtk_file_chooser_get_filenames:
594 * @chooser: a #GtkFileChooser
596 * Lists all the selected files and subfolders in the current folder of
597 * @chooser. The returned names are full absolute paths. If files in the current
598 * folder cannot be represented as local filenames they will be ignored. (See
599 * gtk_file_chooser_get_uris())
601 * Return value: a #GSList containing the filenames of all selected
602 * files and subfolders in the current folder. Free the returned list
603 * with g_slist_free(), and the filenames with g_free().
608 gtk_file_chooser_get_filenames (GtkFileChooser *chooser)
610 GtkFileSystem *file_system;
614 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
616 file_system = _gtk_file_chooser_get_file_system (chooser);
617 paths = _gtk_file_chooser_get_paths (chooser);
619 result = file_paths_to_strings (file_system, paths, gtk_file_system_path_to_filename);
620 gtk_file_paths_free (paths);
625 * gtk_file_chooser_set_current_folder:
626 * @chooser: a #GtkFileChooser
627 * @filename: the full path of the new current folder
629 * Sets the current folder for @chooser from a local filename.
630 * The user will be shown the full contents of the current folder,
631 * plus user interface elements for navigating to other folders.
633 * Return value: %TRUE if the folder could be changed successfully, %FALSE
639 gtk_file_chooser_set_current_folder (GtkFileChooser *chooser,
640 const gchar *filename)
642 GtkFileSystem *file_system;
646 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
647 g_return_val_if_fail (filename != NULL, FALSE);
649 file_system = _gtk_file_chooser_get_file_system (chooser);
651 path = gtk_file_system_filename_to_path (file_system, filename);
654 result = _gtk_file_chooser_set_current_folder_path (chooser, path, NULL);
655 gtk_file_path_free (path);
664 * gtk_file_chooser_get_current_folder:
665 * @chooser: a #GtkFileChooser
667 * Gets the current folder of @chooser as a local filename.
668 * See gtk_file_chooser_set_current_folder().
670 * Return value: the full path of the current folder, or %NULL
671 * if the current path cannot be represented as a local filename.
672 * Free with g_free().
677 gtk_file_chooser_get_current_folder (GtkFileChooser *chooser)
679 GtkFileSystem *file_system;
683 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
685 file_system = _gtk_file_chooser_get_file_system (chooser);
687 path = _gtk_file_chooser_get_current_folder_path (chooser);
688 filename = gtk_file_system_path_to_filename (file_system, path);
689 gtk_file_path_free (path);
695 * gtk_file_chooser_set_current_name:
696 * @chooser: a #GtkFileChooser
697 * @name: the filename to use, as a UTF-8 string
699 * Sets the current name in the file selector, as if entered
700 * by the user. Note that the name passed in here is a UTF-8
701 * string rather than a filename. This function is meant for
702 * such uses as a suggested name in a "Save As..." dialog.
704 * If you want to preselect a particular existing file, you
705 * should use gtk_file_chooser_set_filename() instead.
710 gtk_file_chooser_set_current_name (GtkFileChooser *chooser,
713 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
714 g_return_if_fail (name != NULL);
716 GTK_FILE_CHOOSER_GET_IFACE (chooser)->set_current_name (chooser, name);
720 * gtk_file_chooser_get_uri:
721 * @chooser: a #GtkFileChooser
723 * Gets the URI for the currently selected file in
724 * the file selector. If multiple files are selected,
725 * one of the filenames will be returned at random.
727 * If the file chooser is in folder mode, this function returns the selected
730 * Return value: The currently selected URI, or %NULL
731 * if no file is selected. Free with g_free()
736 gtk_file_chooser_get_uri (GtkFileChooser *chooser)
738 GtkFileSystem *file_system;
740 gchar *result = NULL;
742 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
744 file_system = _gtk_file_chooser_get_file_system (chooser);
745 path = gtk_file_chooser_get_path (chooser);
748 result = gtk_file_system_path_to_uri (file_system, path);
749 gtk_file_path_free (path);
756 * gtk_file_chooser_set_uri:
757 * @chooser: a #GtkFileChooser
758 * @uri: the URI to set as current
760 * Sets the file referred to by @uri as the current file for the
761 * file chooser; If the file name isn't in the current folder of @chooser,
762 * then the current folder of @chooser will be changed to the folder containing
763 * @uri. This is equivalent to a sequence of gtk_file_chooser_unselect_all()
764 * followed by gtk_file_chooser_select_uri().
766 * Note that the file must exist, or nothing will be done except
767 * for the directory change. To pre-enter a filename for the user, as in
768 * a save-as dialog, use gtk_file_chooser_set_current_name()
770 * Return value: %TRUE if both the folder could be changed and the URI was
771 * selected successfully, %FALSE otherwise.
776 gtk_file_chooser_set_uri (GtkFileChooser *chooser,
779 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
781 gtk_file_chooser_unselect_all (chooser);
782 return gtk_file_chooser_select_uri (chooser, uri);
786 * gtk_file_chooser_select_uri:
787 * @chooser: a #GtkFileChooser
788 * @uri: the URI to select
790 * Selects the file to by @uri. If the URI doesn't refer to a
791 * file in the current folder of @chooser, then the current folder of
792 * @chooser will be changed to the folder containing @filename.
794 * Return value: %TRUE if both the folder could be changed and the URI was
795 * selected successfully, %FALSE otherwise.
800 gtk_file_chooser_select_uri (GtkFileChooser *chooser,
803 GtkFileSystem *file_system;
807 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
808 g_return_val_if_fail (uri != NULL, FALSE);
810 file_system = _gtk_file_chooser_get_file_system (chooser);
812 path = gtk_file_system_uri_to_path (file_system, uri);
815 result = _gtk_file_chooser_select_path (chooser, path, NULL);
816 gtk_file_path_free (path);
825 * gtk_file_chooser_unselect_uri:
826 * @chooser: a #GtkFileChooser
827 * @uri: the URI to unselect
829 * Unselects the file referred to by @uri. If the file
830 * is not in the current directory, does not exist, or
831 * is otherwise not currently selected, does nothing.
836 gtk_file_chooser_unselect_uri (GtkFileChooser *chooser,
839 GtkFileSystem *file_system;
842 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
843 g_return_if_fail (uri != NULL);
845 file_system = _gtk_file_chooser_get_file_system (chooser);
847 path = gtk_file_system_uri_to_path (file_system, uri);
850 _gtk_file_chooser_unselect_path (chooser, path);
851 gtk_file_path_free (path);
856 * gtk_file_chooser_select_all:
857 * @chooser: a #GtkFileChooser
859 * Selects all the files in the current folder of a file chooser.
864 gtk_file_chooser_select_all (GtkFileChooser *chooser)
866 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
868 GTK_FILE_CHOOSER_GET_IFACE (chooser)->select_all (chooser);
872 * gtk_file_chooser_unselect_all:
873 * @chooser: a #GtkFileChooser
875 * Unselects all the files in the current folder of a file chooser.
880 gtk_file_chooser_unselect_all (GtkFileChooser *chooser)
883 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
885 GTK_FILE_CHOOSER_GET_IFACE (chooser)->unselect_all (chooser);
889 * gtk_file_chooser_get_uris:
890 * @chooser: a #GtkFileChooser
892 * Lists all the selected files and subfolders in the current folder of
893 * @chooser. The returned names are full absolute URIs.
895 * Return value: a #GSList containing the URIs of all selected
896 * files and subfolders in the current folder. Free the returned list
897 * with g_slist_free(), and the filenames with g_free().
902 gtk_file_chooser_get_uris (GtkFileChooser *chooser)
904 GtkFileSystem *file_system;
908 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
910 file_system = _gtk_file_chooser_get_file_system (chooser);
911 paths = _gtk_file_chooser_get_paths (chooser);
913 result = file_paths_to_strings (file_system, paths, gtk_file_system_path_to_uri);
914 gtk_file_paths_free (paths);
919 * gtk_file_chooser_set_current_folder_uri:
920 * @chooser: a #GtkFileChooser
921 * @uri: the URI for the new current folder
923 * Sets the current folder for @chooser from an URI.
924 * The user will be shown the full contents of the current folder,
925 * plus user interface elements for navigating to other folders.
927 * Return value: %TRUE if the folder could be changed successfully, %FALSE
933 gtk_file_chooser_set_current_folder_uri (GtkFileChooser *chooser,
936 GtkFileSystem *file_system;
940 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
941 g_return_val_if_fail (uri != NULL, FALSE);
943 file_system = _gtk_file_chooser_get_file_system (chooser);
945 path = gtk_file_system_uri_to_path (file_system, uri);
948 result = _gtk_file_chooser_set_current_folder_path (chooser, path, NULL);
949 gtk_file_path_free (path);
958 * gtk_file_chooser_get_current_folder_uri:
959 * @chooser: a #GtkFileChooser
961 * Gets the current folder of @chooser as an URI.
962 * See gtk_file_chooser_set_current_folder_uri().
964 * Return value: the URI for the current folder.
965 * Free with g_free().
970 gtk_file_chooser_get_current_folder_uri (GtkFileChooser *chooser)
972 GtkFileSystem *file_system;
976 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
978 file_system = _gtk_file_chooser_get_file_system (chooser);
980 path = _gtk_file_chooser_get_current_folder_path (chooser);
981 uri = gtk_file_system_path_to_uri (file_system, path);
982 gtk_file_path_free (path);
988 * _gtk_file_chooser_set_current_folder_path:
989 * @chooser: a #GtkFileChooser
990 * @path: the #GtkFilePath for the new folder
991 * @error: location to store error, or %NULL.
993 * Sets the current folder for @chooser from a #GtkFilePath.
994 * Internal function, see gtk_file_chooser_set_current_folder_uri().
996 * Return value: %TRUE if the folder could be changed successfully, %FALSE
1002 _gtk_file_chooser_set_current_folder_path (GtkFileChooser *chooser,
1003 const GtkFilePath *path,
1006 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1007 g_return_val_if_fail (path != NULL, FALSE);
1008 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
1010 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->set_current_folder (chooser, path, error);
1014 * _gtk_file_chooser_get_current_folder_path:
1015 * @chooser: a #GtkFileChooser
1017 * Gets the current folder of @chooser as #GtkFilePath.
1018 * See gtk_file_chooser_get_current_folder_uri().
1020 * Return value: the #GtkFilePath for the current folder.
1021 * Free with gtk_file_path_free().
1026 _gtk_file_chooser_get_current_folder_path (GtkFileChooser *chooser)
1028 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1030 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_current_folder (chooser);
1034 * _gtk_file_chooser_select_path:
1035 * @chooser: a #GtkFileChooser
1036 * @path: the path to select
1037 * @error: location to store error, or %NULL
1039 * Selects the file referred to by @path. An internal function. See
1040 * _gtk_file_chooser_select_uri().
1042 * Return value: %TRUE if both the folder could be changed and the path was
1043 * selected successfully, %FALSE otherwise.
1048 _gtk_file_chooser_select_path (GtkFileChooser *chooser,
1049 const GtkFilePath *path,
1052 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1053 g_return_val_if_fail (path != NULL, FALSE);
1054 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
1056 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->select_path (chooser, path, error);
1060 * _gtk_file_chooser_unselect_path:
1061 * @chooser: a #GtkFileChooser
1062 * @path: the filename to path
1064 * Unselects the file referred to by @path. An internal
1065 * function. See _gtk_file_chooser_unselect_uri().
1070 _gtk_file_chooser_unselect_path (GtkFileChooser *chooser,
1071 const GtkFilePath *path)
1073 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1075 GTK_FILE_CHOOSER_GET_IFACE (chooser)->unselect_path (chooser, path);
1079 * _gtk_file_chooser_get_paths:
1080 * @chooser: a #GtkFileChooser
1082 * Lists all the selected files and subfolders in the current folder of @chooser
1083 * as #GtkFilePath. An internal function, see gtk_file_chooser_get_uris().
1085 * Return value: a #GSList containing a #GtkFilePath for each selected
1086 * file and subfolder in the current folder. Free the returned list
1087 * with g_slist_free(), and the paths with gtk_file_path_free().
1092 _gtk_file_chooser_get_paths (GtkFileChooser *chooser)
1094 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1096 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_paths (chooser);
1099 static GtkFilePath *
1100 gtk_file_chooser_get_path (GtkFileChooser *chooser)
1103 GtkFilePath *result = NULL;
1105 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1107 list = _gtk_file_chooser_get_paths (chooser);
1110 result = list->data;
1111 list = g_slist_delete_link (list, list);
1112 gtk_file_paths_free (list);
1119 * _gtk_file_chooser_get_file_system:
1120 * @chooser: a #GtkFileChooser
1122 * Gets the #GtkFileSystem of @chooser; this is an internal
1123 * implementation detail, used for conversion between paths
1124 * and filenames and URIs.
1126 * Return value: the file system for @chooser.
1131 _gtk_file_chooser_get_file_system (GtkFileChooser *chooser)
1133 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1135 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_file_system (chooser);
1141 * gtk_file_chooser_set_preview_widget:
1142 * @chooser: a #GtkFileChooser
1143 * @preview_widget: widget for displaying preview.
1145 * Sets an application-supplied widget to use to display a custom preview
1146 * of the currently selected file. To implement a preview, after setting the
1147 * preview widget, you connect to the ::update-preview
1148 * signal, and call gtk_file_chooser_get_preview_filename() or
1149 * gtk_file_chooser_get_preview_uri() on each change. If you can
1150 * display a preview of the new file, update your widget and
1151 * set the preview active using gtk_file_chooser_set_preview_widget_active().
1152 * Otherwise, set the preview inactive.
1154 * When there is no application-supplied preview widget, or the
1155 * application-supplied preview widget is not active, the file chooser
1156 * may display an internally generated preview of the current file or
1157 * it may display no preview at all.
1162 gtk_file_chooser_set_preview_widget (GtkFileChooser *chooser,
1163 GtkWidget *preview_widget)
1165 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1167 g_object_set (chooser, "preview-widget", preview_widget, NULL);
1171 * gtk_file_chooser_get_preview_widget:
1172 * @chooser: a #GtkFileChooser
1174 * Gets the current preview widget; see
1175 * gtk_file_chooser_set_preview_widget().
1177 * Return value: the current preview widget, or %NULL
1182 gtk_file_chooser_get_preview_widget (GtkFileChooser *chooser)
1184 GtkWidget *preview_widget;
1186 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1188 g_object_get (chooser, "preview-widget", &preview_widget, NULL);
1190 /* Horrid hack; g_object_get() refs returned objects but
1191 * that contradicts the memory management conventions
1195 g_object_unref (preview_widget);
1197 return preview_widget;
1201 * gtk_file_chooser_set_preview_widget_active:
1202 * @chooser: a #GtkFileChooser
1203 * @active: whether to display the user-specified preview widget
1205 * Sets whether the preview widget set by
1206 * gtk_file_chooser_set_preview_widget() should be shown for the
1207 * current filename. When @active is set to false, the file chooser
1208 * may display an internally generated preview of the current file
1209 * or it may display no preview at all. See
1210 * gtk_file_chooser_set_preview_widget() for more details.
1215 gtk_file_chooser_set_preview_widget_active (GtkFileChooser *chooser,
1218 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1220 g_object_set (chooser, "preview-widget-active", active, NULL);
1224 * gtk_file_chooser_get_preview_widget_active:
1225 * @chooser: a #GtkFileChooser
1227 * Gets whether the preview widget set by gtk_file_chooser_set_preview_widget()
1228 * should be shown for the current filename. See
1229 * gtk_file_chooser_set_preview_widget_active().
1231 * Return value: %TRUE if the preview widget is active for the current filename.
1236 gtk_file_chooser_get_preview_widget_active (GtkFileChooser *chooser)
1240 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1242 g_object_get (chooser, "preview-widget-active", &active, NULL);
1248 * gtk_file_chooser_set_use_preview_label:
1249 * @chooser: a #GtkFileChooser
1250 * @use_label: whether to display a stock label with the name of the previewed file
1252 * Sets whether the file chooser should display a stock label with the name of
1253 * the file that is being previewed; the default is %TRUE. Applications that
1254 * want to draw the whole preview area themselves should set this to %FALSE and
1255 * display the name themselves in their preview widget.
1257 * See also: gtk_file_chooser_set_preview_widget()
1262 gtk_file_chooser_set_use_preview_label (GtkFileChooser *chooser,
1265 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1267 g_object_set (chooser, "use-preview-label", use_label, NULL);
1271 * gtk_file_chooser_get_use_preview_label:
1272 * @chooser: a #GtkFileChooser
1274 * Gets whether a stock label should be drawn with the name of the previewed
1275 * file. See gtk_file_chooser_set_use_preview_label().
1277 * Return value: %TRUE if the file chooser is set to display a label with the
1278 * name of the previewed file, %FALSE otherwise.
1281 gtk_file_chooser_get_use_preview_label (GtkFileChooser *chooser)
1285 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1287 g_object_get (chooser, "use-preview-label", &use_label, NULL);
1293 * gtk_file_chooser_get_preview_filename:
1294 * @chooser: a #GtkFileChooser
1296 * Gets the filename that should be previewed in a custom preview
1297 * Internal function, see gtk_file_chooser_get_preview_uri().
1299 * Return value: the #GtkFilePath for the file to preview, or %NULL if no file
1300 * is selected. Free with gtk_file_path_free().
1305 _gtk_file_chooser_get_preview_path (GtkFileChooser *chooser)
1307 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1309 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_preview_path (chooser);
1313 * _gtk_file_chooser_add_shortcut_folder:
1314 * @chooser: a #GtkFileChooser
1315 * @path: path of the folder to add
1316 * @error: location to store error, or %NULL
1318 * Adds a folder to be displayed with the shortcut folders in a file chooser.
1319 * Internal function, see gtk_file_chooser_add_shortcut_folder().
1321 * Return value: %TRUE if the folder could be added successfully, %FALSE
1327 _gtk_file_chooser_add_shortcut_folder (GtkFileChooser *chooser,
1328 const GtkFilePath *path,
1331 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1332 g_return_val_if_fail (path != NULL, FALSE);
1334 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_shortcut_folder (chooser, path, error);
1338 * _gtk_file_chooser_remove_shortcut_folder:
1339 * @chooser: a #GtkFileChooser
1340 * @path: path of the folder to remove
1341 * @error: location to store error, or %NULL
1343 * Removes a folder from the shortcut folders in a file chooser. Internal
1344 * function, see gtk_file_chooser_remove_shortcut_folder().
1346 * Return value: %TRUE if the folder could be removed successfully, %FALSE
1352 _gtk_file_chooser_remove_shortcut_folder (GtkFileChooser *chooser,
1353 const GtkFilePath *path,
1356 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1357 g_return_val_if_fail (path != NULL, FALSE);
1359 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_shortcut_folder (chooser, path, error);
1363 * gtk_file_chooser_get_preview_filename:
1364 * @chooser: a #GtkFileChooser
1366 * Gets the filename that should be previewed in a custom preview
1367 * widget. See gtk_file_chooser_set_preview_widget().
1369 * Return value: the filename to preview, or %NULL if no file
1370 * is selected, or if the selected file cannot be represented
1371 * as a local filename. Free with g_free()
1376 gtk_file_chooser_get_preview_filename (GtkFileChooser *chooser)
1378 GtkFileSystem *file_system;
1380 gchar *result = NULL;
1382 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1384 file_system = _gtk_file_chooser_get_file_system (chooser);
1385 path = _gtk_file_chooser_get_preview_path (chooser);
1388 result = gtk_file_system_path_to_filename (file_system, path);
1389 gtk_file_path_free (path);
1396 * gtk_file_chooser_get_preview_uri:
1397 * @chooser: a #GtkFileChooser
1399 * Gets the URI that should be previewed in a custom preview
1400 * widget. See gtk_file_chooser_set_preview_widget().
1402 * Return value: the URI for the file to preview, or %NULL if no file is
1403 * selected. Free with g_free().
1408 gtk_file_chooser_get_preview_uri (GtkFileChooser *chooser)
1410 GtkFileSystem *file_system;
1412 gchar *result = NULL;
1414 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1416 file_system = _gtk_file_chooser_get_file_system (chooser);
1417 path = _gtk_file_chooser_get_preview_path (chooser);
1420 result = gtk_file_system_path_to_uri (file_system, path);
1421 gtk_file_path_free (path);
1428 * gtk_file_chooser_set_extra_widget:
1429 * @chooser: a #GtkFileChooser
1430 * @extra_widget: widget for extra options
1432 * Sets an application-supplied widget to provide extra options to the user.
1437 gtk_file_chooser_set_extra_widget (GtkFileChooser *chooser,
1438 GtkWidget *extra_widget)
1440 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1442 g_object_set (chooser, "extra-widget", extra_widget, NULL);
1446 * gtk_file_chooser_get_extra_widget:
1447 * @chooser: a #GtkFileChooser
1449 * Gets the current preview widget; see
1450 * gtk_file_chooser_set_extra_widget().
1452 * Return value: the current extra widget, or %NULL
1457 gtk_file_chooser_get_extra_widget (GtkFileChooser *chooser)
1459 GtkWidget *extra_widget;
1461 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1463 g_object_get (chooser, "extra-widget", &extra_widget, NULL);
1465 /* Horrid hack; g_object_get() refs returned objects but
1466 * that contradicts the memory management conventions
1470 g_object_unref (extra_widget);
1472 return extra_widget;
1476 * gtk_file_chooser_add_filter:
1477 * @chooser: a #GtkFileChooser
1478 * @filter: a #GtkFileFilter
1480 * Adds @filter to the list of filters that the user can select between.
1481 * When a filter is selected, only files that are passed by that
1482 * filter are displayed.
1484 * Note that the @chooser takes ownership of the filter, so you have to
1485 * ref and sink it if you want to keep a reference.
1490 gtk_file_chooser_add_filter (GtkFileChooser *chooser,
1491 GtkFileFilter *filter)
1493 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1495 GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_filter (chooser, filter);
1499 * gtk_file_chooser_remove_filter:
1500 * @chooser: a #GtkFileChooser
1501 * @filter: a #GtkFileFilter
1503 * Removes @filter from the list of filters that the user can select between.
1508 gtk_file_chooser_remove_filter (GtkFileChooser *chooser,
1509 GtkFileFilter *filter)
1511 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1513 GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_filter (chooser, filter);
1517 * gtk_file_chooser_list_filters:
1518 * @chooser: a #GtkFileChooser
1520 * Lists the current set of user-selectable filters; see
1521 * gtk_file_chooser_add_filter(), gtk_file_chooser_remove_filter().
1523 * Return value: a #GSList containing the current set of
1524 * user selectable filters. The contents of the list are
1525 * owned by GTK+, but you must free the list itself with
1526 * g_slist_free() when you are done with it.
1531 gtk_file_chooser_list_filters (GtkFileChooser *chooser)
1533 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1535 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->list_filters (chooser);
1539 * gtk_file_chooser_set_filter:
1540 * @chooser: a #GtkFileChooser
1541 * @filter: a #GtkFileFilter
1543 * Sets the current filter; only the files that pass the
1544 * filter will be displayed. If the user-selectable list of filters
1545 * is non-empty, then the filter should be one of the filters
1546 * in that list. Setting the current filter when the list of
1547 * filters is empty is useful if you want to restrict the displayed
1548 * set of files without letting the user change it.
1553 gtk_file_chooser_set_filter (GtkFileChooser *chooser,
1554 GtkFileFilter *filter)
1556 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1557 g_return_if_fail (GTK_IS_FILE_FILTER (filter));
1559 g_object_set (chooser, "filter", filter, NULL);
1563 * gtk_file_chooser_get_filter:
1564 * @chooser: a #GtkFileChooser
1566 * Gets the current filter; see gtk_file_chooser_set_filter().
1568 * Return value: the current filter, or %NULL
1573 gtk_file_chooser_get_filter (GtkFileChooser *chooser)
1575 GtkFileFilter *filter;
1577 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1579 g_object_get (chooser, "filter", &filter, NULL);
1580 /* Horrid hack; g_object_get() refs returned objects but
1581 * that contradicts the memory management conventions
1585 g_object_unref (filter);
1591 * gtk_file_chooser_add_shortcut_folder:
1592 * @chooser: a #GtkFileChooser
1593 * @folder: filename of the folder to add
1594 * @error: location to store error, or %NULL
1596 * Adds a folder to be displayed with the shortcut folders in a file chooser.
1597 * Note that shortcut folders do not get saved, as they are provided by the
1598 * application. For example, you can use this to add a
1599 * "/usr/share/mydrawprogram/Clipart" folder to the volume list.
1601 * Return value: %TRUE if the folder could be added successfully, %FALSE
1602 * otherwise. In the latter case, the @error will be set as appropriate.
1607 gtk_file_chooser_add_shortcut_folder (GtkFileChooser *chooser,
1614 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1615 g_return_val_if_fail (folder != NULL, FALSE);
1617 path = gtk_file_system_filename_to_path (_gtk_file_chooser_get_file_system (chooser), folder);
1621 GTK_FILE_CHOOSER_ERROR,
1622 GTK_FILE_CHOOSER_ERROR_BAD_FILENAME,
1623 _("Invalid filename: %s"),
1628 result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_shortcut_folder (chooser, path, error);
1630 gtk_file_path_free (path);
1636 * gtk_file_chooser_remove_shortcut_folder:
1637 * @chooser: a #GtkFileChooser
1638 * @folder: filename of the folder to remove
1639 * @error: location to store error, or %NULL
1641 * Removes a folder from a file chooser's list of shortcut folders.
1643 * Return value: %TRUE if the operation succeeds, %FALSE otherwise.
1644 * In the latter case, the @error will be set as appropriate.
1646 * See also: gtk_file_chooser_add_shortcut_folder()
1651 gtk_file_chooser_remove_shortcut_folder (GtkFileChooser *chooser,
1658 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1659 g_return_val_if_fail (folder != NULL, FALSE);
1661 path = gtk_file_system_filename_to_path (_gtk_file_chooser_get_file_system (chooser), folder);
1665 GTK_FILE_CHOOSER_ERROR,
1666 GTK_FILE_CHOOSER_ERROR_BAD_FILENAME,
1667 _("Invalid filename: %s"),
1672 result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_shortcut_folder (chooser, path, error);
1674 gtk_file_path_free (path);
1680 * gtk_file_chooser_list_shortcut_folders:
1681 * @chooser: a #GtkFileChooser
1683 * Queries the list of shortcut folders in the file chooser, as set by
1684 * gtk_file_chooser_add_shortcut_folder().
1686 * Return value: A list of folder filenames, or %NULL if there are no shortcut
1687 * folders. Free the returned list with g_slist_free(), and the filenames with
1693 gtk_file_chooser_list_shortcut_folders (GtkFileChooser *chooser)
1698 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1700 folders = GTK_FILE_CHOOSER_GET_IFACE (chooser)->list_shortcut_folders (chooser);
1702 result = file_paths_to_strings (_gtk_file_chooser_get_file_system (chooser),
1704 gtk_file_system_path_to_filename);
1705 gtk_file_paths_free (folders);
1710 * gtk_file_chooser_add_shortcut_folder_uri:
1711 * @chooser: a #GtkFileChooser
1712 * @uri: URI of the folder to add
1713 * @error: location to store error, or %NULL
1715 * Adds a folder URI to be displayed with the shortcut folders in a file
1716 * chooser. Note that shortcut folders do not get saved, as they are provided
1717 * by the application. For example, you can use this to add a
1718 * "file:///usr/share/mydrawprogram/Clipart" folder to the volume list.
1720 * Return value: %TRUE if the folder could be added successfully, %FALSE
1721 * otherwise. In the latter case, the @error will be set as appropriate.
1726 gtk_file_chooser_add_shortcut_folder_uri (GtkFileChooser *chooser,
1733 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1734 g_return_val_if_fail (uri != NULL, FALSE);
1736 path = gtk_file_system_uri_to_path (_gtk_file_chooser_get_file_system (chooser), uri);
1740 GTK_FILE_CHOOSER_ERROR,
1741 GTK_FILE_CHOOSER_ERROR_BAD_FILENAME,
1742 _("Invalid filename: %s"),
1747 result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_shortcut_folder (chooser, path, error);
1749 gtk_file_path_free (path);
1755 * gtk_file_chooser_remove_shortcut_folder_uri:
1756 * @chooser: a #GtkFileChooser
1757 * @uri: URI of the folder to remove
1758 * @error: location to store error, or %NULL
1760 * Removes a folder URI from a file chooser's list of shortcut folders.
1762 * Return value: %TRUE if the operation succeeds, %FALSE otherwise.
1763 * In the latter case, the @error will be set as appropriate.
1765 * See also: gtk_file_chooser_add_shortcut_folder_uri()
1770 gtk_file_chooser_remove_shortcut_folder_uri (GtkFileChooser *chooser,
1777 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1778 g_return_val_if_fail (uri != NULL, FALSE);
1780 path = gtk_file_system_uri_to_path (_gtk_file_chooser_get_file_system (chooser), uri);
1784 GTK_FILE_CHOOSER_ERROR,
1785 GTK_FILE_CHOOSER_ERROR_BAD_FILENAME,
1786 _("Invalid filename: %s"),
1791 result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_shortcut_folder (chooser, path, error);
1793 gtk_file_path_free (path);
1799 * gtk_file_chooser_list_shortcut_folder_uris:
1800 * @chooser: a #GtkFileChooser
1802 * Queries the list of shortcut folders in the file chooser, as set by
1803 * gtk_file_chooser_add_shortcut_folder_uri().
1805 * Return value: A list of folder URIs, or %NULL if there are no shortcut
1806 * folders. Free the returned list with g_slist_free(), and the URIs with
1812 gtk_file_chooser_list_shortcut_folder_uris (GtkFileChooser *chooser)
1817 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1819 folders = GTK_FILE_CHOOSER_GET_IFACE (chooser)->list_shortcut_folders (chooser);
1821 result = file_paths_to_strings (_gtk_file_chooser_get_file_system (chooser),
1823 gtk_file_system_path_to_uri);
1824 gtk_file_paths_free (folders);
1830 * gtk_file_chooser_set_show_hidden:
1831 * @chooser: a #GtkFileChooser
1832 * @show_hidden: %TRUE if hidden files and folders should be displayed.
1834 * Sets whether hidden files and folders are displayed in the file selector.
1839 gtk_file_chooser_set_show_hidden (GtkFileChooser *chooser,
1840 gboolean show_hidden)
1842 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1844 g_object_set (chooser, "show-hidden", show_hidden, NULL);
1848 * gtk_file_chooser_get_show_hidden:
1849 * @chooser: a #GtkFileChooser
1851 * Gets whether hidden files and folders are displayed in the file selector.
1852 * See gtk_file_chooser_set_show_hidden().
1854 * Return value: %TRUE if hidden files and folders are displayed.
1859 gtk_file_chooser_get_show_hidden (GtkFileChooser *chooser)
1861 gboolean show_hidden;
1863 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1865 g_object_get (chooser, "show-hidden", &show_hidden, NULL);
1871 * gtk_file_chooser_set_do_overwrite_confirmation:
1872 * @chooser: a #GtkFileChooser
1873 * @do_overwrite_confirmation: whether to confirm overwriting in save mode
1875 * Sets whether a file chooser in GTK_FILE_CHOOSER_ACTION_SAVE mode will present
1876 * a confirmation dialog if the user types a file name that already exists. This
1877 * is %FALSE by default.
1879 * Regardless of this setting, the @chooser will emit the "confirm-overwrite"
1880 * signal when appropriate.
1882 * If all you need is the stock confirmation dialog, set this property to %TRUE.
1883 * You can override the way confirmation is done by actually handling the
1884 * "confirm-overwrite" signal; please refer to its documentation for the
1890 gtk_file_chooser_set_do_overwrite_confirmation (GtkFileChooser *chooser,
1891 gboolean do_overwrite_confirmation)
1893 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1895 g_object_set (chooser, "do-overwrite-confirmation", do_overwrite_confirmation, NULL);
1899 * gtk_file_chooser_get_do_overwrite_confirmation:
1900 * @chooser: a #GtkFileChooser
1902 * Queries whether a file chooser is set to confirm for overwriting when the user
1903 * types a file name that already exists.
1905 * Return value: %TRUE if the file chooser will present a confirmation dialog;
1911 gtk_file_chooser_get_do_overwrite_confirmation (GtkFileChooser *chooser)
1913 gboolean do_overwrite_confirmation;
1915 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1917 g_object_get (chooser, "do-overwrite-confirmation", &do_overwrite_confirmation, NULL);
1919 return do_overwrite_confirmation;
1924 /* DLL ABI stability backward compatibility versions */
1926 #undef gtk_file_chooser_get_filename
1929 gtk_file_chooser_get_filename (GtkFileChooser *chooser)
1931 gchar *utf8_filename = gtk_file_chooser_get_filename_utf8 (chooser);
1932 gchar *retval = g_locale_from_utf8 (utf8_filename, -1, NULL, NULL, NULL);
1934 g_free (utf8_filename);
1939 #undef gtk_file_chooser_set_filename
1942 gtk_file_chooser_set_filename (GtkFileChooser *chooser,
1943 const gchar *filename)
1945 gchar *utf8_filename = g_locale_to_utf8 (filename, -1, NULL, NULL, NULL);
1946 gboolean retval = gtk_file_chooser_set_filename_utf8 (chooser, utf8_filename);
1948 g_free (utf8_filename);
1953 #undef gtk_file_chooser_select_filename
1956 gtk_file_chooser_select_filename (GtkFileChooser *chooser,
1957 const gchar *filename)
1959 gchar *utf8_filename = g_locale_to_utf8 (filename, -1, NULL, NULL, NULL);
1960 gboolean retval = gtk_file_chooser_select_filename_utf8 (chooser, utf8_filename);
1962 g_free (utf8_filename);
1967 #undef gtk_file_chooser_unselect_filename
1970 gtk_file_chooser_unselect_filename (GtkFileChooser *chooser,
1971 const char *filename)
1973 gchar *utf8_filename = g_locale_to_utf8 (filename, -1, NULL, NULL, NULL);
1975 gtk_file_chooser_unselect_filename_utf8 (chooser, utf8_filename);
1976 g_free (utf8_filename);
1979 #undef gtk_file_chooser_get_filenames
1982 gtk_file_chooser_get_filenames (GtkFileChooser *chooser)
1984 GSList *list = gtk_file_chooser_get_filenames_utf8 (chooser);
1985 GSList *rover = list;
1989 gchar *tem = (gchar *) rover->data;
1990 rover->data = g_locale_from_utf8 ((gchar *) rover->data, -1, NULL, NULL, NULL);
1992 rover = rover->next;
1998 #undef gtk_file_chooser_set_current_folder
2001 gtk_file_chooser_set_current_folder (GtkFileChooser *chooser,
2002 const gchar *filename)
2004 gchar *utf8_filename = g_locale_to_utf8 (filename, -1, NULL, NULL, NULL);
2005 gboolean retval = gtk_file_chooser_set_current_folder_utf8 (chooser, utf8_filename);
2007 g_free (utf8_filename);
2012 #undef gtk_file_chooser_get_current_folder
2015 gtk_file_chooser_get_current_folder (GtkFileChooser *chooser)
2017 gchar *utf8_folder = gtk_file_chooser_get_current_folder_utf8 (chooser);
2018 gchar *retval = g_locale_from_utf8 (utf8_folder, -1, NULL, NULL, NULL);
2020 g_free (utf8_folder);
2025 #undef gtk_file_chooser_get_preview_filename
2028 gtk_file_chooser_get_preview_filename (GtkFileChooser *chooser)
2030 char *utf8_filename = gtk_file_chooser_get_preview_filename_utf8 (chooser);
2031 char *retval = g_locale_from_utf8 (utf8_filename, -1, NULL, NULL, NULL);
2033 g_free (utf8_filename);
2038 #undef gtk_file_chooser_add_shortcut_folder
2041 gtk_file_chooser_add_shortcut_folder (GtkFileChooser *chooser,
2045 char *utf8_folder = g_locale_to_utf8 (folder, -1, NULL, NULL, NULL);
2047 gtk_file_chooser_add_shortcut_folder_utf8 (chooser, utf8_folder, error);
2049 g_free (utf8_folder);
2054 #undef gtk_file_chooser_remove_shortcut_folder
2057 gtk_file_chooser_remove_shortcut_folder (GtkFileChooser *chooser,
2061 char *utf8_folder = g_locale_to_utf8 (folder, -1, NULL, NULL, NULL);
2063 gtk_file_chooser_remove_shortcut_folder_utf8 (chooser, utf8_folder, error);
2065 g_free (utf8_folder);
2070 #undef gtk_file_chooser_list_shortcut_folders
2073 gtk_file_chooser_list_shortcut_folders (GtkFileChooser *chooser)
2075 GSList *list = gtk_file_chooser_list_shortcut_folders_utf8 (chooser);
2076 GSList *rover = list;
2080 gchar *tem = (gchar *) rover->data;
2081 rover->data = g_locale_from_utf8 ((gchar *) rover->data, -1, NULL, NULL, NULL);
2083 rover = rover->next;
2091 #define __GTK_FILE_CHOOSER_C__
2092 #include "gtkaliasdef.c"