1 /* GTK - The GIMP Toolkit
2 * gtkfilechooser.c: Abstract interface for file selector GUIs
3 * Copyright (C) 2003, Red Hat, Inc.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
22 #include "gtkfilechooser.h"
23 #include "gtkfilechooserprivate.h"
24 #include "gtkfilesystem.h"
26 #include "gtktypebuiltins.h"
27 #include "gtkprivate.h"
28 #include "gtkmarshalers.h"
31 static void gtk_file_chooser_class_init (gpointer g_iface);
33 static GtkFilePath *gtk_file_chooser_get_path (GtkFileChooser *chooser);
36 gtk_file_chooser_get_type (void)
38 static GType file_chooser_type = 0;
40 if (!file_chooser_type)
42 file_chooser_type = g_type_register_static_simple (G_TYPE_INTERFACE,
44 sizeof (GtkFileChooserIface),
45 gtk_file_chooser_class_init,
48 g_type_interface_add_prerequisite (file_chooser_type, GTK_TYPE_WIDGET);
51 return file_chooser_type;
55 confirm_overwrite_accumulator (GSignalInvocationHint *ihint,
57 const GValue *handler_return,
60 gboolean continue_emission;
61 GtkFileChooserConfirmation conf;
63 conf = g_value_get_enum (handler_return);
64 g_value_set_enum (return_accu, conf);
65 continue_emission = (conf == GTK_FILE_CHOOSER_CONFIRMATION_CONFIRM);
67 return continue_emission;
71 gtk_file_chooser_class_init (gpointer g_iface)
73 GType iface_type = G_TYPE_FROM_INTERFACE (g_iface);
76 * GtkFileChooser::current-folder-changed
77 * @chooser: the object which received the signal.
79 * This signal is emitted when the current folder in a #GtkFileChooser
80 * changes. This can happen due to the user performing some action that
81 * changes folders, such as selecting a bookmark or visiting a folder on the
82 * file list. It can also happen as a result of calling a function to
83 * explicitly change the current folder in a file chooser.
85 * Normally you do not need to connect to this signal, unless you need to keep
86 * track of which folder a file chooser is showing.
88 * See also: gtk_file_chooser_set_current_folder(),
89 * gtk_file_chooser_get_current_folder(),
90 * gtk_file_chooser_set_current_folder_uri(),
91 * gtk_file_chooser_get_current_folder_uri().
93 g_signal_new (I_("current-folder-changed"),
96 G_STRUCT_OFFSET (GtkFileChooserIface, current_folder_changed),
98 g_cclosure_marshal_VOID__VOID,
102 * GtkFileChooser::selection-changed
103 * @chooser: the object which received the signal.
105 * This signal is emitted when there is a change in the set of selected files
106 * in a #GtkFileChooser. This can happen when the user modifies the selection
107 * with the mouse or the keyboard, or when explicitly calling functions to
108 * change the selection.
110 * Normally you do not need to connect to this signal, as it is easier to wait
111 * for the file chooser to finish running, and then to get the list of
112 * selected files using the functions mentioned below.
114 * See also: gtk_file_chooser_select_filename(),
115 * gtk_file_chooser_unselect_filename(), gtk_file_chooser_get_filename(),
116 * gtk_file_chooser_get_filenames(), gtk_file_chooser_select_uri(),
117 * gtk_file_chooser_unselect_uri(), gtk_file_chooser_get_uri(),
118 * gtk_file_chooser_get_uris().
120 g_signal_new (I_("selection-changed"),
123 G_STRUCT_OFFSET (GtkFileChooserIface, selection_changed),
125 g_cclosure_marshal_VOID__VOID,
129 * GtkFileChooser::update-preview
130 * @chooser: the object which received the signal.
132 * This signal is emitted when the preview in a file chooser should be
133 * regenerated. For example, this can happen when the currently selected file
134 * changes. You should use this signal if you want your file chooser to have
137 * Once you have installed a preview widget with
138 * gtk_file_chooser_set_preview_widget(), you should update it when this
139 * signal is emitted. You can use the functions
140 * gtk_file_chooser_get_preview_filename() or
141 * gtk_file_chooser_get_preview_uri() to get the name of the file to preview.
142 * Your widget may not be able to preview all kinds of files; your callback
143 * must call gtk_file_chooser_set_preview_wiget_active() to inform the file
144 * chooser about whether the preview was generated successfully or not.
146 * Please see the example code in <xref linkend="gtkfilechooser-preview"/>.
148 * See also: gtk_file_chooser_set_preview_widget(),
149 * gtk_file_chooser_set_preview_widget_active(),
150 * gtk_file_chooser_set_use_preview_label(),
151 * gtk_file_chooser_get_preview_filename(),
152 * gtk_file_chooser_get_preview_uri().
154 g_signal_new (I_("update-preview"),
157 G_STRUCT_OFFSET (GtkFileChooserIface, update_preview),
159 g_cclosure_marshal_VOID__VOID,
163 * GtkFileChooser::file-activated
164 * @chooser: the object which received the signal.
166 * This signal is emitted when the user "activates" a file in the file
167 * chooser. This can happen by double-clicking on a file in the file list, or
168 * by pressing <keycap>Enter</keycap>.
170 * Normally you do not need to connect to this signal. It is used internally
171 * by #GtkFileChooserDialog to know when to activate the default button in the
174 * See also: gtk_file_chooser_get_filename(),
175 * gtk_file_chooser_get_filenames(), gtk_file_chooser_get_uri(),
176 * gtk_file_chooser_get_uris().
178 g_signal_new (I_("file-activated"),
181 G_STRUCT_OFFSET (GtkFileChooserIface, file_activated),
183 g_cclosure_marshal_VOID__VOID,
186 /* Documented in the docbook files */
187 g_signal_new (I_("confirm-overwrite"),
190 G_STRUCT_OFFSET (GtkFileChooserIface, confirm_overwrite),
191 confirm_overwrite_accumulator, NULL,
192 _gtk_marshal_ENUM__VOID,
193 GTK_TYPE_FILE_CHOOSER_CONFIRMATION, 0);
195 g_object_interface_install_property (g_iface,
196 g_param_spec_enum ("action",
198 P_("The type of operation that the file selector is performing"),
199 GTK_TYPE_FILE_CHOOSER_ACTION,
200 GTK_FILE_CHOOSER_ACTION_OPEN,
201 GTK_PARAM_READWRITE));
202 g_object_interface_install_property (g_iface,
203 g_param_spec_string ("file-system-backend",
204 P_("File System Backend"),
205 P_("Name of file system backend to use"),
207 GTK_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
208 g_object_interface_install_property (g_iface,
209 g_param_spec_object ("filter",
211 P_("The current filter for selecting which files are displayed"),
212 GTK_TYPE_FILE_FILTER,
213 GTK_PARAM_READWRITE));
214 g_object_interface_install_property (g_iface,
215 g_param_spec_boolean ("local-only",
217 P_("Whether the selected file(s) should be limited to local file: URLs"),
219 GTK_PARAM_READWRITE));
220 g_object_interface_install_property (g_iface,
221 g_param_spec_object ("preview-widget",
222 P_("Preview widget"),
223 P_("Application supplied widget for custom previews."),
225 GTK_PARAM_READWRITE));
226 g_object_interface_install_property (g_iface,
227 g_param_spec_boolean ("preview-widget-active",
228 P_("Preview Widget Active"),
229 P_("Whether the application supplied widget for custom previews should be shown."),
231 GTK_PARAM_READWRITE));
232 g_object_interface_install_property (g_iface,
233 g_param_spec_boolean ("use-preview-label",
234 P_("Use Preview Label"),
235 P_("Whether to display a stock label with the name of the previewed file."),
237 GTK_PARAM_READWRITE));
238 g_object_interface_install_property (g_iface,
239 g_param_spec_object ("extra-widget",
241 P_("Application supplied widget for extra options."),
243 GTK_PARAM_READWRITE));
244 g_object_interface_install_property (g_iface,
245 g_param_spec_boolean ("select-multiple",
246 P_("Select Multiple"),
247 P_("Whether to allow multiple files to be selected"),
249 GTK_PARAM_READWRITE));
251 g_object_interface_install_property (g_iface,
252 g_param_spec_boolean ("show-hidden",
254 P_("Whether the hidden files and folders should be displayed"),
256 GTK_PARAM_READWRITE));
259 * GtkFileChooser:do-overwrite-confirmation:
261 * Whether a file chooser in %GTK_FILE_CHOOSER_ACTION_SAVE mode
262 * will present an overwrite confirmation dialog if the user
263 * selects a file name that already exists.
267 g_object_interface_install_property (g_iface,
268 g_param_spec_boolean ("do-overwrite-confirmation",
269 P_("Do overwrite confirmation"),
270 P_("Whether a file chooser in save mode "
271 "will present an overwrite confirmation dialog "
274 GTK_PARAM_READWRITE));
278 * gtk_file_chooser_error_quark:
280 * Registers an error quark for #GtkFileChooser if necessary.
282 * Return value: The error quark used for #GtkFileChooser errors.
287 gtk_file_chooser_error_quark (void)
289 return g_quark_from_static_string ("gtk-file-chooser-error-quark");
293 * gtk_file_chooser_set_action:
294 * @chooser: a #GtkFileChooser
295 * @action: the action that the file selector is performing
297 * Sets the type of operation that the chooser is performing; the
298 * user interface is adapted to suit the selected action. For example,
299 * an option to create a new folder might be shown if the action is
300 * %GTK_FILE_CHOOSER_ACTION_SAVE but not if the action is
301 * %GTK_FILE_CHOOSER_ACTION_OPEN.
306 gtk_file_chooser_set_action (GtkFileChooser *chooser,
307 GtkFileChooserAction action)
309 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
311 g_object_set (chooser, "action", action, NULL);
315 * gtk_file_chooser_get_action:
316 * @chooser: a #GtkFileChooser
318 * Gets the type of operation that the file chooser is performing; see
319 * gtk_file_chooser_set_action().
321 * Return value: the action that the file selector is performing
326 gtk_file_chooser_get_action (GtkFileChooser *chooser)
328 GtkFileChooserAction action;
330 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
332 g_object_get (chooser, "action", &action, NULL);
338 * gtk_file_chooser_set_local_only:
339 * @chooser: a #GtkFileChooser
340 * @local_only: %TRUE if only local files can be selected
342 * Sets whether only local files can be selected in the
343 * file selector. If @local_only is %TRUE (the default),
344 * then the selected file are files are guaranteed to be
345 * accessible through the operating systems native file
346 * file system and therefore the application only
347 * needs to worry about the filename functions in
348 * #GtkFileChooser, like gtk_file_chooser_get_filename(),
349 * rather than the URI functions like
350 * gtk_file_chooser_get_uri(),
355 gtk_file_chooser_set_local_only (GtkFileChooser *chooser,
358 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
360 g_object_set (chooser, "local-only", local_only, NULL);
364 * gtk_file_chooser_get_local_only:
365 * @chooser: a #GtkFileChoosre
367 * Gets whether only local files can be selected in the
368 * file selector. See gtk_file_chooser_set_local_only()
370 * Return value: %TRUE if only local files can be selected.
375 gtk_file_chooser_get_local_only (GtkFileChooser *chooser)
379 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
381 g_object_get (chooser, "local-only", &local_only, NULL);
387 * gtk_file_chooser_set_select_multiple:
388 * @chooser: a #GtkFileChooser
389 * @select_multiple: %TRUE if multiple files can be selected.
391 * Sets whether multiple files can be selected in the file selector. This is
392 * only relevant if the action is set to be GTK_FILE_CHOOSER_ACTION_OPEN or
393 * GTK_FILE_CHOOSER_ACTION_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, by changing
473 * to the file's parent folder and actually selecting the file in list. If
474 * the @chooser is in #GTK_FILE_CHOOSER_ACTION_SAVE mode, the file's base name
475 * will also appear in the dialog's file name entry.
477 * If the file name isn't in the current folder of @chooser, then the current
478 * folder of @chooser will be changed to the folder containing @filename. This
479 * is equivalent to a sequence of gtk_file_chooser_unselect_all() followed by
480 * gtk_file_chooser_select_filename().
482 * Note that the file must exist, or nothing will be done except
483 * for the directory change.
485 * If you are implementing a <guimenuitem>File/Save As...</guimenuitem> dialog, you
486 * should use this function if you already have a file name to which the user may save; for example,
487 * when the user opens an existing file and then does <guimenuitem>File/Save As...</guimenuitem>
488 * on it. If you don't have a file name already — for example, if the user just created
489 * a new file and is saving it for the first time, do not call this function. Instead, use
490 * something similar to this:
493 * if (document_is_new)
495 * /<!-- -->* the user just created a new document *<!-- -->/
496 * gtk_file_chooser_set_current_folder (chooser, default_folder_for_saving);
497 * gtk_file_chooser_set_current_name (chooser, "Untitled document");
501 * /<!-- -->* the user edited an existing document *<!-- -->/
502 * gtk_file_chooser_set_filename (chooser, existing_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_set_filename (GtkFileChooser *chooser,
513 const gchar *filename)
515 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
517 gtk_file_chooser_unselect_all (chooser);
518 return gtk_file_chooser_select_filename (chooser, filename);
522 * gtk_file_chooser_select_filename:
523 * @chooser: a #GtkFileChooser
524 * @filename: the filename to select
526 * Selects a filename. If the file name isn't in the current
527 * folder of @chooser, then the current folder of @chooser will
528 * be changed to the folder containing @filename.
530 * Return value: %TRUE if both the folder could be changed and the file was
531 * selected successfully, %FALSE otherwise.
536 gtk_file_chooser_select_filename (GtkFileChooser *chooser,
537 const gchar *filename)
539 GtkFileSystem *file_system;
543 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
544 g_return_val_if_fail (filename != NULL, FALSE);
546 file_system = _gtk_file_chooser_get_file_system (chooser);
548 path = gtk_file_system_filename_to_path (file_system, filename);
551 result = _gtk_file_chooser_select_path (chooser, path, NULL);
552 gtk_file_path_free (path);
561 * gtk_file_chooser_unselect_filename:
562 * @chooser: a #GtkFileChooser
563 * @filename: the filename to unselect
565 * Unselects a currently selected filename. If the filename
566 * is not in the current directory, does not exist, or
567 * is otherwise not currently selected, does nothing.
572 gtk_file_chooser_unselect_filename (GtkFileChooser *chooser,
573 const char *filename)
575 GtkFileSystem *file_system;
578 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
579 g_return_if_fail (filename != NULL);
581 file_system = _gtk_file_chooser_get_file_system (chooser);
583 path = gtk_file_system_filename_to_path (file_system, filename);
586 _gtk_file_chooser_unselect_path (chooser, path);
587 gtk_file_path_free (path);
591 /* Converts a list of GtkFilePath* to a list of strings using the specified function */
593 file_paths_to_strings (GtkFileSystem *fs,
595 gchar * (*convert_func) (GtkFileSystem *fs, const GtkFilePath *path))
601 for (; paths; paths = paths->next)
607 string = (* convert_func) (fs, path);
610 strings = g_slist_prepend (strings, string);
613 return g_slist_reverse (strings);
617 * gtk_file_chooser_get_filenames:
618 * @chooser: a #GtkFileChooser
620 * Lists all the selected files and subfolders in the current folder of
621 * @chooser. The returned names are full absolute paths. If files in the current
622 * folder cannot be represented as local filenames they will be ignored. (See
623 * gtk_file_chooser_get_uris())
625 * Return value: a #GSList containing the filenames of all selected
626 * files and subfolders in the current folder. Free the returned list
627 * with g_slist_free(), and the filenames with g_free().
632 gtk_file_chooser_get_filenames (GtkFileChooser *chooser)
634 GtkFileSystem *file_system;
638 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
640 file_system = _gtk_file_chooser_get_file_system (chooser);
641 paths = _gtk_file_chooser_get_paths (chooser);
643 result = file_paths_to_strings (file_system, paths, gtk_file_system_path_to_filename);
644 gtk_file_paths_free (paths);
649 * gtk_file_chooser_set_current_folder:
650 * @chooser: a #GtkFileChooser
651 * @filename: the full path of the new current folder
653 * Sets the current folder for @chooser from a local filename.
654 * The user will be shown the full contents of the current folder,
655 * plus user interface elements for navigating to other folders.
657 * Return value: %TRUE if the folder could be changed successfully, %FALSE
663 gtk_file_chooser_set_current_folder (GtkFileChooser *chooser,
664 const gchar *filename)
666 GtkFileSystem *file_system;
670 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
671 g_return_val_if_fail (filename != NULL, FALSE);
673 file_system = _gtk_file_chooser_get_file_system (chooser);
675 path = gtk_file_system_filename_to_path (file_system, filename);
678 result = _gtk_file_chooser_set_current_folder_path (chooser, path, NULL);
679 gtk_file_path_free (path);
688 * gtk_file_chooser_get_current_folder:
689 * @chooser: a #GtkFileChooser
691 * Gets the current folder of @chooser as a local filename.
692 * See gtk_file_chooser_set_current_folder().
694 * Return value: the full path of the current folder, or %NULL if the current
695 * path cannot be represented as a local filename. Free with g_free(). This
696 * function will also return %NULL if the file chooser was unable to load the
697 * last folder that was requested from it; for example, as would be for calling
698 * gtk_file_chooser_set_current_folder() on a nonexistent folder.
703 gtk_file_chooser_get_current_folder (GtkFileChooser *chooser)
705 GtkFileSystem *file_system;
709 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
711 file_system = _gtk_file_chooser_get_file_system (chooser);
713 path = _gtk_file_chooser_get_current_folder_path (chooser);
717 filename = gtk_file_system_path_to_filename (file_system, path);
718 gtk_file_path_free (path);
724 * gtk_file_chooser_set_current_name:
725 * @chooser: a #GtkFileChooser
726 * @name: the filename to use, as a UTF-8 string
728 * Sets the current name in the file selector, as if entered
729 * by the user. Note that the name passed in here is a UTF-8
730 * string rather than a filename. This function is meant for
731 * such uses as a suggested name in a "Save As..." dialog.
733 * If you want to preselect a particular existing file, you should use
734 * gtk_file_chooser_set_filename() or gtk_file_chooser_set_uri() instead.
735 * Please see the documentation for those functions for an example of using
736 * gtk_file_chooser_set_current_name() as well.
741 gtk_file_chooser_set_current_name (GtkFileChooser *chooser,
744 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
745 g_return_if_fail (name != NULL);
747 GTK_FILE_CHOOSER_GET_IFACE (chooser)->set_current_name (chooser, name);
751 * gtk_file_chooser_get_uri:
752 * @chooser: a #GtkFileChooser
754 * Gets the URI for the currently selected file in
755 * the file selector. If multiple files are selected,
756 * one of the filenames will be returned at random.
758 * If the file chooser is in folder mode, this function returns the selected
761 * Return value: The currently selected URI, or %NULL
762 * if no file is selected. Free with g_free()
767 gtk_file_chooser_get_uri (GtkFileChooser *chooser)
769 GtkFileSystem *file_system;
771 gchar *result = NULL;
773 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
775 file_system = _gtk_file_chooser_get_file_system (chooser);
776 path = gtk_file_chooser_get_path (chooser);
779 result = gtk_file_system_path_to_uri (file_system, path);
780 gtk_file_path_free (path);
787 * gtk_file_chooser_set_uri:
788 * @chooser: a #GtkFileChooser
789 * @uri: the URI to set as current
791 * Sets the file referred to by @uri as the current file for the file chooser,
792 * by changing to the URI's parent folder and actually selecting the URI in the
793 * list. If the @chooser is #GTK_FILE_CHOOSER_ACTION_SAVE mode, the URI's base
794 * name will also appear in the dialog's file name entry.
796 * If the URI isn't in the current folder of @chooser, then the current folder
797 * of @chooser will be changed to the folder containing @uri. This is equivalent
798 * to a sequence of gtk_file_chooser_unselect_all() followed by
799 * gtk_file_chooser_select_uri().
801 * Note that the URI must exist, or nothing will be done except
802 * for the directory change.
803 * If you are implementing a <guimenuitem>File/Save As...</guimenuitem> dialog, you
804 * should use this function if you already have a file name to which the user may save; for example,
805 * when the user opens an existing file and then does <guimenuitem>File/Save As...</guimenuitem>
806 * on it. If you don't have a file name already — for example, if the user just created
807 * a new file and is saving it for the first time, do not call this function. Instead, use
808 * something similar to this:
811 * if (document_is_new)
813 * /<!-- -->* the user just created a new document *<!-- -->/
814 * gtk_file_chooser_set_current_folder_uri (chooser, default_folder_for_saving);
815 * gtk_file_chooser_set_current_name (chooser, "Untitled document");
819 * /<!-- -->* the user edited an existing document *<!-- -->/
820 * gtk_file_chooser_set_uri (chooser, existing_uri);
824 * Return value: %TRUE if both the folder could be changed and the URI was
825 * selected successfully, %FALSE otherwise.
830 gtk_file_chooser_set_uri (GtkFileChooser *chooser,
833 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
835 gtk_file_chooser_unselect_all (chooser);
836 return gtk_file_chooser_select_uri (chooser, uri);
840 * gtk_file_chooser_select_uri:
841 * @chooser: a #GtkFileChooser
842 * @uri: the URI to select
844 * Selects the file to by @uri. If the URI doesn't refer to a
845 * file in the current folder of @chooser, then the current folder of
846 * @chooser will be changed to the folder containing @filename.
848 * Return value: %TRUE if both the folder could be changed and the URI was
849 * selected successfully, %FALSE otherwise.
854 gtk_file_chooser_select_uri (GtkFileChooser *chooser,
857 GtkFileSystem *file_system;
861 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
862 g_return_val_if_fail (uri != NULL, FALSE);
864 file_system = _gtk_file_chooser_get_file_system (chooser);
866 path = gtk_file_system_uri_to_path (file_system, uri);
869 result = _gtk_file_chooser_select_path (chooser, path, NULL);
870 gtk_file_path_free (path);
879 * gtk_file_chooser_unselect_uri:
880 * @chooser: a #GtkFileChooser
881 * @uri: the URI to unselect
883 * Unselects the file referred to by @uri. If the file
884 * is not in the current directory, does not exist, or
885 * is otherwise not currently selected, does nothing.
890 gtk_file_chooser_unselect_uri (GtkFileChooser *chooser,
893 GtkFileSystem *file_system;
896 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
897 g_return_if_fail (uri != NULL);
899 file_system = _gtk_file_chooser_get_file_system (chooser);
901 path = gtk_file_system_uri_to_path (file_system, uri);
904 _gtk_file_chooser_unselect_path (chooser, path);
905 gtk_file_path_free (path);
910 * gtk_file_chooser_select_all:
911 * @chooser: a #GtkFileChooser
913 * Selects all the files in the current folder of a file chooser.
918 gtk_file_chooser_select_all (GtkFileChooser *chooser)
920 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
922 GTK_FILE_CHOOSER_GET_IFACE (chooser)->select_all (chooser);
926 * gtk_file_chooser_unselect_all:
927 * @chooser: a #GtkFileChooser
929 * Unselects all the files in the current folder of a file chooser.
934 gtk_file_chooser_unselect_all (GtkFileChooser *chooser)
937 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
939 GTK_FILE_CHOOSER_GET_IFACE (chooser)->unselect_all (chooser);
943 * gtk_file_chooser_get_uris:
944 * @chooser: a #GtkFileChooser
946 * Lists all the selected files and subfolders in the current folder of
947 * @chooser. The returned names are full absolute URIs.
949 * Return value: a #GSList containing the URIs of all selected
950 * files and subfolders in the current folder. Free the returned list
951 * with g_slist_free(), and the filenames with g_free().
956 gtk_file_chooser_get_uris (GtkFileChooser *chooser)
958 GtkFileSystem *file_system;
962 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
964 file_system = _gtk_file_chooser_get_file_system (chooser);
965 paths = _gtk_file_chooser_get_paths (chooser);
967 result = file_paths_to_strings (file_system, paths, gtk_file_system_path_to_uri);
968 gtk_file_paths_free (paths);
973 * gtk_file_chooser_set_current_folder_uri:
974 * @chooser: a #GtkFileChooser
975 * @uri: the URI for the new current folder
977 * Sets the current folder for @chooser from an URI.
978 * The user will be shown the full contents of the current folder,
979 * plus user interface elements for navigating to other folders.
981 * Return value: %TRUE if the folder could be changed successfully, %FALSE
987 gtk_file_chooser_set_current_folder_uri (GtkFileChooser *chooser,
990 GtkFileSystem *file_system;
994 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
995 g_return_val_if_fail (uri != NULL, FALSE);
997 file_system = _gtk_file_chooser_get_file_system (chooser);
999 path = gtk_file_system_uri_to_path (file_system, uri);
1002 result = _gtk_file_chooser_set_current_folder_path (chooser, path, NULL);
1003 gtk_file_path_free (path);
1012 * gtk_file_chooser_get_current_folder_uri:
1013 * @chooser: a #GtkFileChooser
1015 * Gets the current folder of @chooser as an URI.
1016 * See gtk_file_chooser_set_current_folder_uri().
1018 * Return value: the URI for the current folder. Free with g_free(). This
1019 * function will also return %NULL if the file chooser was unable to load the
1020 * last folder that was requested from it; for example, as would be for calling
1021 * gtk_file_chooser_set_current_folder_uri() on a nonexistent folder.
1026 gtk_file_chooser_get_current_folder_uri (GtkFileChooser *chooser)
1028 GtkFileSystem *file_system;
1032 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1034 file_system = _gtk_file_chooser_get_file_system (chooser);
1036 path = _gtk_file_chooser_get_current_folder_path (chooser);
1037 uri = gtk_file_system_path_to_uri (file_system, path);
1038 gtk_file_path_free (path);
1044 * _gtk_file_chooser_set_current_folder_path:
1045 * @chooser: a #GtkFileChooser
1046 * @path: the #GtkFilePath for the new folder
1047 * @error: location to store error, or %NULL.
1049 * Sets the current folder for @chooser from a #GtkFilePath.
1050 * Internal function, see gtk_file_chooser_set_current_folder_uri().
1052 * Return value: %TRUE if the folder could be changed successfully, %FALSE
1058 _gtk_file_chooser_set_current_folder_path (GtkFileChooser *chooser,
1059 const GtkFilePath *path,
1062 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1063 g_return_val_if_fail (path != NULL, FALSE);
1064 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
1066 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->set_current_folder (chooser, path, error);
1070 * _gtk_file_chooser_get_current_folder_path:
1071 * @chooser: a #GtkFileChooser
1073 * Gets the current folder of @chooser as #GtkFilePath.
1074 * See gtk_file_chooser_get_current_folder_uri().
1076 * Return value: the #GtkFilePath for the current folder.
1077 * Free with gtk_file_path_free().
1082 _gtk_file_chooser_get_current_folder_path (GtkFileChooser *chooser)
1084 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1086 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_current_folder (chooser);
1090 * _gtk_file_chooser_select_path:
1091 * @chooser: a #GtkFileChooser
1092 * @path: the path to select
1093 * @error: location to store error, or %NULL
1095 * Selects the file referred to by @path. An internal function. See
1096 * _gtk_file_chooser_select_uri().
1098 * Return value: %TRUE if both the folder could be changed and the path was
1099 * selected successfully, %FALSE otherwise.
1104 _gtk_file_chooser_select_path (GtkFileChooser *chooser,
1105 const GtkFilePath *path,
1108 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1109 g_return_val_if_fail (path != NULL, FALSE);
1110 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
1112 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->select_path (chooser, path, error);
1116 * _gtk_file_chooser_unselect_path:
1117 * @chooser: a #GtkFileChooser
1118 * @path: the filename to path
1120 * Unselects the file referred to by @path. An internal
1121 * function. See _gtk_file_chooser_unselect_uri().
1126 _gtk_file_chooser_unselect_path (GtkFileChooser *chooser,
1127 const GtkFilePath *path)
1129 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1131 GTK_FILE_CHOOSER_GET_IFACE (chooser)->unselect_path (chooser, path);
1135 * _gtk_file_chooser_get_paths:
1136 * @chooser: a #GtkFileChooser
1138 * Lists all the selected files and subfolders in the current folder of @chooser
1139 * as #GtkFilePath. An internal function, see gtk_file_chooser_get_uris().
1141 * Return value: a #GSList containing a #GtkFilePath for each selected
1142 * file and subfolder in the current folder. Free the returned list
1143 * with g_slist_free(), and the paths with gtk_file_path_free().
1148 _gtk_file_chooser_get_paths (GtkFileChooser *chooser)
1150 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1152 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_paths (chooser);
1155 static GtkFilePath *
1156 gtk_file_chooser_get_path (GtkFileChooser *chooser)
1159 GtkFilePath *result = NULL;
1161 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1163 list = _gtk_file_chooser_get_paths (chooser);
1166 result = list->data;
1167 list = g_slist_delete_link (list, list);
1168 gtk_file_paths_free (list);
1175 * _gtk_file_chooser_get_file_system:
1176 * @chooser: a #GtkFileChooser
1178 * Gets the #GtkFileSystem of @chooser; this is an internal
1179 * implementation detail, used for conversion between paths
1180 * and filenames and URIs.
1182 * Return value: the file system for @chooser.
1187 _gtk_file_chooser_get_file_system (GtkFileChooser *chooser)
1189 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1191 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_file_system (chooser);
1197 * gtk_file_chooser_set_preview_widget:
1198 * @chooser: a #GtkFileChooser
1199 * @preview_widget: widget for displaying preview.
1201 * Sets an application-supplied widget to use to display a custom preview
1202 * of the currently selected file. To implement a preview, after setting the
1203 * preview widget, you connect to the ::update-preview
1204 * signal, and call gtk_file_chooser_get_preview_filename() or
1205 * gtk_file_chooser_get_preview_uri() on each change. If you can
1206 * display a preview of the new file, update your widget and
1207 * set the preview active using gtk_file_chooser_set_preview_widget_active().
1208 * Otherwise, set the preview inactive.
1210 * When there is no application-supplied preview widget, or the
1211 * application-supplied preview widget is not active, the file chooser
1212 * may display an internally generated preview of the current file or
1213 * it may display no preview at all.
1218 gtk_file_chooser_set_preview_widget (GtkFileChooser *chooser,
1219 GtkWidget *preview_widget)
1221 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1223 g_object_set (chooser, "preview-widget", preview_widget, NULL);
1227 * gtk_file_chooser_get_preview_widget:
1228 * @chooser: a #GtkFileChooser
1230 * Gets the current preview widget; see
1231 * gtk_file_chooser_set_preview_widget().
1233 * Return value: the current preview widget, or %NULL
1238 gtk_file_chooser_get_preview_widget (GtkFileChooser *chooser)
1240 GtkWidget *preview_widget;
1242 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1244 g_object_get (chooser, "preview-widget", &preview_widget, NULL);
1246 /* Horrid hack; g_object_get() refs returned objects but
1247 * that contradicts the memory management conventions
1251 g_object_unref (preview_widget);
1253 return preview_widget;
1257 * gtk_file_chooser_set_preview_widget_active:
1258 * @chooser: a #GtkFileChooser
1259 * @active: whether to display the user-specified preview widget
1261 * Sets whether the preview widget set by
1262 * gtk_file_chooser_set_preview_widget() should be shown for the
1263 * current filename. When @active is set to false, the file chooser
1264 * may display an internally generated preview of the current file
1265 * or it may display no preview at all. See
1266 * gtk_file_chooser_set_preview_widget() for more details.
1271 gtk_file_chooser_set_preview_widget_active (GtkFileChooser *chooser,
1274 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1276 g_object_set (chooser, "preview-widget-active", active, NULL);
1280 * gtk_file_chooser_get_preview_widget_active:
1281 * @chooser: a #GtkFileChooser
1283 * Gets whether the preview widget set by gtk_file_chooser_set_preview_widget()
1284 * should be shown for the current filename. See
1285 * gtk_file_chooser_set_preview_widget_active().
1287 * Return value: %TRUE if the preview widget is active for the current filename.
1292 gtk_file_chooser_get_preview_widget_active (GtkFileChooser *chooser)
1296 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1298 g_object_get (chooser, "preview-widget-active", &active, NULL);
1304 * gtk_file_chooser_set_use_preview_label:
1305 * @chooser: a #GtkFileChooser
1306 * @use_label: whether to display a stock label with the name of the previewed file
1308 * Sets whether the file chooser should display a stock label with the name of
1309 * the file that is being previewed; the default is %TRUE. Applications that
1310 * want to draw the whole preview area themselves should set this to %FALSE and
1311 * display the name themselves in their preview widget.
1313 * See also: gtk_file_chooser_set_preview_widget()
1318 gtk_file_chooser_set_use_preview_label (GtkFileChooser *chooser,
1321 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1323 g_object_set (chooser, "use-preview-label", use_label, NULL);
1327 * gtk_file_chooser_get_use_preview_label:
1328 * @chooser: a #GtkFileChooser
1330 * Gets whether a stock label should be drawn with the name of the previewed
1331 * file. See gtk_file_chooser_set_use_preview_label().
1333 * Return value: %TRUE if the file chooser is set to display a label with the
1334 * name of the previewed file, %FALSE otherwise.
1337 gtk_file_chooser_get_use_preview_label (GtkFileChooser *chooser)
1341 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1343 g_object_get (chooser, "use-preview-label", &use_label, NULL);
1349 * gtk_file_chooser_get_preview_filename:
1350 * @chooser: a #GtkFileChooser
1352 * Gets the filename that should be previewed in a custom preview
1353 * Internal function, see gtk_file_chooser_get_preview_uri().
1355 * Return value: the #GtkFilePath for the file to preview, or %NULL if no file
1356 * is selected. Free with gtk_file_path_free().
1361 _gtk_file_chooser_get_preview_path (GtkFileChooser *chooser)
1363 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1365 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_preview_path (chooser);
1369 * _gtk_file_chooser_add_shortcut_folder:
1370 * @chooser: a #GtkFileChooser
1371 * @path: path of the folder to add
1372 * @error: location to store error, or %NULL
1374 * Adds a folder to be displayed with the shortcut folders in a file chooser.
1375 * Internal function, see gtk_file_chooser_add_shortcut_folder().
1377 * Return value: %TRUE if the folder could be added successfully, %FALSE
1383 _gtk_file_chooser_add_shortcut_folder (GtkFileChooser *chooser,
1384 const GtkFilePath *path,
1387 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1388 g_return_val_if_fail (path != NULL, FALSE);
1390 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_shortcut_folder (chooser, path, error);
1394 * _gtk_file_chooser_remove_shortcut_folder:
1395 * @chooser: a #GtkFileChooser
1396 * @path: path of the folder to remove
1397 * @error: location to store error, or %NULL
1399 * Removes a folder from the shortcut folders in a file chooser. Internal
1400 * function, see gtk_file_chooser_remove_shortcut_folder().
1402 * Return value: %TRUE if the folder could be removed successfully, %FALSE
1408 _gtk_file_chooser_remove_shortcut_folder (GtkFileChooser *chooser,
1409 const GtkFilePath *path,
1412 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1413 g_return_val_if_fail (path != NULL, FALSE);
1415 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_shortcut_folder (chooser, path, error);
1419 * gtk_file_chooser_get_preview_filename:
1420 * @chooser: a #GtkFileChooser
1422 * Gets the filename that should be previewed in a custom preview
1423 * widget. See gtk_file_chooser_set_preview_widget().
1425 * Return value: the filename to preview, or %NULL if no file
1426 * is selected, or if the selected file cannot be represented
1427 * as a local filename. Free with g_free()
1432 gtk_file_chooser_get_preview_filename (GtkFileChooser *chooser)
1434 GtkFileSystem *file_system;
1436 gchar *result = NULL;
1438 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1440 file_system = _gtk_file_chooser_get_file_system (chooser);
1441 path = _gtk_file_chooser_get_preview_path (chooser);
1444 result = gtk_file_system_path_to_filename (file_system, path);
1445 gtk_file_path_free (path);
1452 * gtk_file_chooser_get_preview_uri:
1453 * @chooser: a #GtkFileChooser
1455 * Gets the URI that should be previewed in a custom preview
1456 * widget. See gtk_file_chooser_set_preview_widget().
1458 * Return value: the URI for the file to preview, or %NULL if no file is
1459 * selected. Free with g_free().
1464 gtk_file_chooser_get_preview_uri (GtkFileChooser *chooser)
1466 GtkFileSystem *file_system;
1468 gchar *result = NULL;
1470 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1472 file_system = _gtk_file_chooser_get_file_system (chooser);
1473 path = _gtk_file_chooser_get_preview_path (chooser);
1476 result = gtk_file_system_path_to_uri (file_system, path);
1477 gtk_file_path_free (path);
1484 * gtk_file_chooser_set_extra_widget:
1485 * @chooser: a #GtkFileChooser
1486 * @extra_widget: widget for extra options
1488 * Sets an application-supplied widget to provide extra options to the user.
1493 gtk_file_chooser_set_extra_widget (GtkFileChooser *chooser,
1494 GtkWidget *extra_widget)
1496 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1498 g_object_set (chooser, "extra-widget", extra_widget, NULL);
1502 * gtk_file_chooser_get_extra_widget:
1503 * @chooser: a #GtkFileChooser
1505 * Gets the current preview widget; see
1506 * gtk_file_chooser_set_extra_widget().
1508 * Return value: the current extra widget, or %NULL
1513 gtk_file_chooser_get_extra_widget (GtkFileChooser *chooser)
1515 GtkWidget *extra_widget;
1517 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1519 g_object_get (chooser, "extra-widget", &extra_widget, NULL);
1521 /* Horrid hack; g_object_get() refs returned objects but
1522 * that contradicts the memory management conventions
1526 g_object_unref (extra_widget);
1528 return extra_widget;
1532 * gtk_file_chooser_add_filter:
1533 * @chooser: a #GtkFileChooser
1534 * @filter: a #GtkFileFilter
1536 * Adds @filter to the list of filters that the user can select between.
1537 * When a filter is selected, only files that are passed by that
1538 * filter are displayed.
1540 * Note that the @chooser takes ownership of the filter, so you have to
1541 * ref and sink it if you want to keep a reference.
1546 gtk_file_chooser_add_filter (GtkFileChooser *chooser,
1547 GtkFileFilter *filter)
1549 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1551 GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_filter (chooser, filter);
1555 * gtk_file_chooser_remove_filter:
1556 * @chooser: a #GtkFileChooser
1557 * @filter: a #GtkFileFilter
1559 * Removes @filter from the list of filters that the user can select between.
1564 gtk_file_chooser_remove_filter (GtkFileChooser *chooser,
1565 GtkFileFilter *filter)
1567 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1569 GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_filter (chooser, filter);
1573 * gtk_file_chooser_list_filters:
1574 * @chooser: a #GtkFileChooser
1576 * Lists the current set of user-selectable filters; see
1577 * gtk_file_chooser_add_filter(), gtk_file_chooser_remove_filter().
1579 * Return value: a #GSList containing the current set of
1580 * user selectable filters. The contents of the list are
1581 * owned by GTK+, but you must free the list itself with
1582 * g_slist_free() when you are done with it.
1587 gtk_file_chooser_list_filters (GtkFileChooser *chooser)
1589 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1591 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->list_filters (chooser);
1595 * gtk_file_chooser_set_filter:
1596 * @chooser: a #GtkFileChooser
1597 * @filter: a #GtkFileFilter
1599 * Sets the current filter; only the files that pass the
1600 * filter will be displayed. If the user-selectable list of filters
1601 * is non-empty, then the filter should be one of the filters
1602 * in that list. Setting the current filter when the list of
1603 * filters is empty is useful if you want to restrict the displayed
1604 * set of files without letting the user change it.
1609 gtk_file_chooser_set_filter (GtkFileChooser *chooser,
1610 GtkFileFilter *filter)
1612 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1613 g_return_if_fail (GTK_IS_FILE_FILTER (filter));
1615 g_object_set (chooser, "filter", filter, NULL);
1619 * gtk_file_chooser_get_filter:
1620 * @chooser: a #GtkFileChooser
1622 * Gets the current filter; see gtk_file_chooser_set_filter().
1624 * Return value: the current filter, or %NULL
1629 gtk_file_chooser_get_filter (GtkFileChooser *chooser)
1631 GtkFileFilter *filter;
1633 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1635 g_object_get (chooser, "filter", &filter, NULL);
1636 /* Horrid hack; g_object_get() refs returned objects but
1637 * that contradicts the memory management conventions
1641 g_object_unref (filter);
1647 * gtk_file_chooser_add_shortcut_folder:
1648 * @chooser: a #GtkFileChooser
1649 * @folder: filename of the folder to add
1650 * @error: location to store error, or %NULL
1652 * Adds a folder to be displayed with the shortcut folders in a file chooser.
1653 * Note that shortcut folders do not get saved, as they are provided by the
1654 * application. For example, you can use this to add a
1655 * "/usr/share/mydrawprogram/Clipart" folder to the volume list.
1657 * Return value: %TRUE if the folder could be added successfully, %FALSE
1658 * otherwise. In the latter case, the @error will be set as appropriate.
1663 gtk_file_chooser_add_shortcut_folder (GtkFileChooser *chooser,
1670 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1671 g_return_val_if_fail (folder != NULL, FALSE);
1673 path = gtk_file_system_filename_to_path (_gtk_file_chooser_get_file_system (chooser), folder);
1677 GTK_FILE_CHOOSER_ERROR,
1678 GTK_FILE_CHOOSER_ERROR_BAD_FILENAME,
1679 _("Invalid filename: %s"),
1684 result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_shortcut_folder (chooser, path, error);
1686 gtk_file_path_free (path);
1692 * gtk_file_chooser_remove_shortcut_folder:
1693 * @chooser: a #GtkFileChooser
1694 * @folder: filename of the folder to remove
1695 * @error: location to store error, or %NULL
1697 * Removes a folder from a file chooser's list of shortcut folders.
1699 * Return value: %TRUE if the operation succeeds, %FALSE otherwise.
1700 * In the latter case, the @error will be set as appropriate.
1702 * See also: gtk_file_chooser_add_shortcut_folder()
1707 gtk_file_chooser_remove_shortcut_folder (GtkFileChooser *chooser,
1714 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1715 g_return_val_if_fail (folder != NULL, FALSE);
1717 path = gtk_file_system_filename_to_path (_gtk_file_chooser_get_file_system (chooser), folder);
1721 GTK_FILE_CHOOSER_ERROR,
1722 GTK_FILE_CHOOSER_ERROR_BAD_FILENAME,
1723 _("Invalid filename: %s"),
1728 result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_shortcut_folder (chooser, path, error);
1730 gtk_file_path_free (path);
1736 * gtk_file_chooser_list_shortcut_folders:
1737 * @chooser: a #GtkFileChooser
1739 * Queries the list of shortcut folders in the file chooser, as set by
1740 * gtk_file_chooser_add_shortcut_folder().
1742 * Return value: A list of folder filenames, or %NULL if there are no shortcut
1743 * folders. Free the returned list with g_slist_free(), and the filenames with
1749 gtk_file_chooser_list_shortcut_folders (GtkFileChooser *chooser)
1754 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1756 folders = GTK_FILE_CHOOSER_GET_IFACE (chooser)->list_shortcut_folders (chooser);
1758 result = file_paths_to_strings (_gtk_file_chooser_get_file_system (chooser),
1760 gtk_file_system_path_to_filename);
1761 gtk_file_paths_free (folders);
1766 * gtk_file_chooser_add_shortcut_folder_uri:
1767 * @chooser: a #GtkFileChooser
1768 * @uri: URI of the folder to add
1769 * @error: location to store error, or %NULL
1771 * Adds a folder URI to be displayed with the shortcut folders in a file
1772 * chooser. Note that shortcut folders do not get saved, as they are provided
1773 * by the application. For example, you can use this to add a
1774 * "file:///usr/share/mydrawprogram/Clipart" folder to the volume list.
1776 * Return value: %TRUE if the folder could be added successfully, %FALSE
1777 * otherwise. In the latter case, the @error will be set as appropriate.
1782 gtk_file_chooser_add_shortcut_folder_uri (GtkFileChooser *chooser,
1789 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1790 g_return_val_if_fail (uri != NULL, FALSE);
1792 path = gtk_file_system_uri_to_path (_gtk_file_chooser_get_file_system (chooser), uri);
1796 GTK_FILE_CHOOSER_ERROR,
1797 GTK_FILE_CHOOSER_ERROR_BAD_FILENAME,
1798 _("Invalid filename: %s"),
1803 result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_shortcut_folder (chooser, path, error);
1805 gtk_file_path_free (path);
1811 * gtk_file_chooser_remove_shortcut_folder_uri:
1812 * @chooser: a #GtkFileChooser
1813 * @uri: URI of the folder to remove
1814 * @error: location to store error, or %NULL
1816 * Removes a folder URI from a file chooser's list of shortcut folders.
1818 * Return value: %TRUE if the operation succeeds, %FALSE otherwise.
1819 * In the latter case, the @error will be set as appropriate.
1821 * See also: gtk_file_chooser_add_shortcut_folder_uri()
1826 gtk_file_chooser_remove_shortcut_folder_uri (GtkFileChooser *chooser,
1833 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1834 g_return_val_if_fail (uri != NULL, FALSE);
1836 path = gtk_file_system_uri_to_path (_gtk_file_chooser_get_file_system (chooser), uri);
1840 GTK_FILE_CHOOSER_ERROR,
1841 GTK_FILE_CHOOSER_ERROR_BAD_FILENAME,
1842 _("Invalid filename: %s"),
1847 result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_shortcut_folder (chooser, path, error);
1849 gtk_file_path_free (path);
1855 * gtk_file_chooser_list_shortcut_folder_uris:
1856 * @chooser: a #GtkFileChooser
1858 * Queries the list of shortcut folders in the file chooser, as set by
1859 * gtk_file_chooser_add_shortcut_folder_uri().
1861 * Return value: A list of folder URIs, or %NULL if there are no shortcut
1862 * folders. Free the returned list with g_slist_free(), and the URIs with
1868 gtk_file_chooser_list_shortcut_folder_uris (GtkFileChooser *chooser)
1873 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1875 folders = GTK_FILE_CHOOSER_GET_IFACE (chooser)->list_shortcut_folders (chooser);
1877 result = file_paths_to_strings (_gtk_file_chooser_get_file_system (chooser),
1879 gtk_file_system_path_to_uri);
1880 gtk_file_paths_free (folders);
1886 * gtk_file_chooser_set_show_hidden:
1887 * @chooser: a #GtkFileChooser
1888 * @show_hidden: %TRUE if hidden files and folders should be displayed.
1890 * Sets whether hidden files and folders are displayed in the file selector.
1895 gtk_file_chooser_set_show_hidden (GtkFileChooser *chooser,
1896 gboolean show_hidden)
1898 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1900 g_object_set (chooser, "show-hidden", show_hidden, NULL);
1904 * gtk_file_chooser_get_show_hidden:
1905 * @chooser: a #GtkFileChooser
1907 * Gets whether hidden files and folders are displayed in the file selector.
1908 * See gtk_file_chooser_set_show_hidden().
1910 * Return value: %TRUE if hidden files and folders are displayed.
1915 gtk_file_chooser_get_show_hidden (GtkFileChooser *chooser)
1917 gboolean show_hidden;
1919 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1921 g_object_get (chooser, "show-hidden", &show_hidden, NULL);
1927 * gtk_file_chooser_set_do_overwrite_confirmation:
1928 * @chooser: a #GtkFileChooser
1929 * @do_overwrite_confirmation: whether to confirm overwriting in save mode
1931 * Sets whether a file chooser in GTK_FILE_CHOOSER_ACTION_SAVE mode will present
1932 * a confirmation dialog if the user types a file name that already exists. This
1933 * is %FALSE by default.
1935 * Regardless of this setting, the @chooser will emit the "confirm-overwrite"
1936 * signal when appropriate.
1938 * If all you need is the stock confirmation dialog, set this property to %TRUE.
1939 * You can override the way confirmation is done by actually handling the
1940 * "confirm-overwrite" signal; please refer to its documentation for the
1946 gtk_file_chooser_set_do_overwrite_confirmation (GtkFileChooser *chooser,
1947 gboolean do_overwrite_confirmation)
1949 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1951 g_object_set (chooser, "do-overwrite-confirmation", do_overwrite_confirmation, NULL);
1955 * gtk_file_chooser_get_do_overwrite_confirmation:
1956 * @chooser: a #GtkFileChooser
1958 * Queries whether a file chooser is set to confirm for overwriting when the user
1959 * types a file name that already exists.
1961 * Return value: %TRUE if the file chooser will present a confirmation dialog;
1967 gtk_file_chooser_get_do_overwrite_confirmation (GtkFileChooser *chooser)
1969 gboolean do_overwrite_confirmation;
1971 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1973 g_object_get (chooser, "do-overwrite-confirmation", &do_overwrite_confirmation, NULL);
1975 return do_overwrite_confirmation;
1980 /* DLL ABI stability backward compatibility versions */
1982 #undef gtk_file_chooser_get_filename
1985 gtk_file_chooser_get_filename (GtkFileChooser *chooser)
1987 gchar *utf8_filename = gtk_file_chooser_get_filename_utf8 (chooser);
1988 gchar *retval = g_locale_from_utf8 (utf8_filename, -1, NULL, NULL, NULL);
1990 g_free (utf8_filename);
1995 #undef gtk_file_chooser_set_filename
1998 gtk_file_chooser_set_filename (GtkFileChooser *chooser,
1999 const gchar *filename)
2001 gchar *utf8_filename = g_locale_to_utf8 (filename, -1, NULL, NULL, NULL);
2002 gboolean retval = gtk_file_chooser_set_filename_utf8 (chooser, utf8_filename);
2004 g_free (utf8_filename);
2009 #undef gtk_file_chooser_select_filename
2012 gtk_file_chooser_select_filename (GtkFileChooser *chooser,
2013 const gchar *filename)
2015 gchar *utf8_filename = g_locale_to_utf8 (filename, -1, NULL, NULL, NULL);
2016 gboolean retval = gtk_file_chooser_select_filename_utf8 (chooser, utf8_filename);
2018 g_free (utf8_filename);
2023 #undef gtk_file_chooser_unselect_filename
2026 gtk_file_chooser_unselect_filename (GtkFileChooser *chooser,
2027 const char *filename)
2029 gchar *utf8_filename = g_locale_to_utf8 (filename, -1, NULL, NULL, NULL);
2031 gtk_file_chooser_unselect_filename_utf8 (chooser, utf8_filename);
2032 g_free (utf8_filename);
2035 #undef gtk_file_chooser_get_filenames
2038 gtk_file_chooser_get_filenames (GtkFileChooser *chooser)
2040 GSList *list = gtk_file_chooser_get_filenames_utf8 (chooser);
2041 GSList *rover = list;
2045 gchar *tem = (gchar *) rover->data;
2046 rover->data = g_locale_from_utf8 ((gchar *) rover->data, -1, NULL, NULL, NULL);
2048 rover = rover->next;
2054 #undef gtk_file_chooser_set_current_folder
2057 gtk_file_chooser_set_current_folder (GtkFileChooser *chooser,
2058 const gchar *filename)
2060 gchar *utf8_filename = g_locale_to_utf8 (filename, -1, NULL, NULL, NULL);
2061 gboolean retval = gtk_file_chooser_set_current_folder_utf8 (chooser, utf8_filename);
2063 g_free (utf8_filename);
2068 #undef gtk_file_chooser_get_current_folder
2071 gtk_file_chooser_get_current_folder (GtkFileChooser *chooser)
2073 gchar *utf8_folder = gtk_file_chooser_get_current_folder_utf8 (chooser);
2074 gchar *retval = g_locale_from_utf8 (utf8_folder, -1, NULL, NULL, NULL);
2076 g_free (utf8_folder);
2081 #undef gtk_file_chooser_get_preview_filename
2084 gtk_file_chooser_get_preview_filename (GtkFileChooser *chooser)
2086 char *utf8_filename = gtk_file_chooser_get_preview_filename_utf8 (chooser);
2087 char *retval = g_locale_from_utf8 (utf8_filename, -1, NULL, NULL, NULL);
2089 g_free (utf8_filename);
2094 #undef gtk_file_chooser_add_shortcut_folder
2097 gtk_file_chooser_add_shortcut_folder (GtkFileChooser *chooser,
2101 char *utf8_folder = g_locale_to_utf8 (folder, -1, NULL, NULL, NULL);
2103 gtk_file_chooser_add_shortcut_folder_utf8 (chooser, utf8_folder, error);
2105 g_free (utf8_folder);
2110 #undef gtk_file_chooser_remove_shortcut_folder
2113 gtk_file_chooser_remove_shortcut_folder (GtkFileChooser *chooser,
2117 char *utf8_folder = g_locale_to_utf8 (folder, -1, NULL, NULL, NULL);
2119 gtk_file_chooser_remove_shortcut_folder_utf8 (chooser, utf8_folder, error);
2121 g_free (utf8_folder);
2126 #undef gtk_file_chooser_list_shortcut_folders
2129 gtk_file_chooser_list_shortcut_folders (GtkFileChooser *chooser)
2131 GSList *list = gtk_file_chooser_list_shortcut_folders_utf8 (chooser);
2132 GSList *rover = list;
2136 gchar *tem = (gchar *) rover->data;
2137 rover->data = g_locale_from_utf8 ((gchar *) rover->data, -1, NULL, NULL, NULL);
2139 rover = rover->next;
2147 #define __GTK_FILE_CHOOSER_C__
2148 #include "gtkaliasdef.c"