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 (I_("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 (I_("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 (I_("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 (I_("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 (I_("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));
265 * GtkFileChooser:do-overwrite-confirmation:
267 * Whether a file chooser in %GTK_FILE_CHOOSER_ACTION_SAVE mode
268 * will present an overwrite confirmation dialog if the user
269 * selects a file name that already exists.
273 g_object_interface_install_property (g_iface,
274 g_param_spec_boolean ("do-overwrite-confirmation",
275 P_("Do overwrite confirmation"),
276 P_("Whether a file chooser in save mode "
277 "will present an overwrite confirmation dialog "
280 GTK_PARAM_READWRITE));
284 * gtk_file_chooser_error_quark:
286 * Registers an error quark for #GtkFileChooser if necessary.
288 * Return value: The error quark used for #GtkFileChooser errors.
293 gtk_file_chooser_error_quark (void)
295 return g_quark_from_static_string ("gtk-file-chooser-error-quark");
299 * gtk_file_chooser_set_action:
300 * @chooser: a #GtkFileChooser
301 * @action: the action that the file selector is performing
303 * Sets the type of operation that the chooser is performing; the
304 * user interface is adapted to suit the selected action. For example,
305 * an option to create a new folder might be shown if the action is
306 * %GTK_FILE_CHOOSER_ACTION_SAVE but not if the action is
307 * %GTK_FILE_CHOOSER_ACTION_OPEN.
312 gtk_file_chooser_set_action (GtkFileChooser *chooser,
313 GtkFileChooserAction action)
315 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
317 g_object_set (chooser, "action", action, NULL);
321 * gtk_file_chooser_get_action:
322 * @chooser: a #GtkFileChooser
324 * Gets the type of operation that the file chooser is performing; see
325 * gtk_file_chooser_set_action().
327 * Return value: the action that the file selector is performing
332 gtk_file_chooser_get_action (GtkFileChooser *chooser)
334 GtkFileChooserAction action;
336 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
338 g_object_get (chooser, "action", &action, NULL);
344 * gtk_file_chooser_set_local_only:
345 * @chooser: a #GtkFileChooser
346 * @local_only: %TRUE if only local files can be selected
348 * Sets whether only local files can be selected in the
349 * file selector. If @local_only is %TRUE (the default),
350 * then the selected file are files are guaranteed to be
351 * accessible through the operating systems native file
352 * file system and therefore the application only
353 * needs to worry about the filename functions in
354 * #GtkFileChooser, like gtk_file_chooser_get_filename(),
355 * rather than the URI functions like
356 * gtk_file_chooser_get_uri(),
361 gtk_file_chooser_set_local_only (GtkFileChooser *chooser,
364 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
366 g_object_set (chooser, "local-only", local_only, NULL);
370 * gtk_file_chooser_get_local_only:
371 * @chooser: a #GtkFileChoosre
373 * Gets whether only local files can be selected in the
374 * file selector. See gtk_file_chooser_set_local_only()
376 * Return value: %TRUE if only local files can be selected.
381 gtk_file_chooser_get_local_only (GtkFileChooser *chooser)
385 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
387 g_object_get (chooser, "local-only", &local_only, NULL);
393 * gtk_file_chooser_set_select_multiple:
394 * @chooser: a #GtkFileChooser
395 * @select_multiple: %TRUE if multiple files can be selected.
397 * Sets whether multiple files can be selected in the file selector. This is
398 * only relevant if the action is set to be GTK_FILE_CHOOSER_ACTION_OPEN or
399 * GTK_FILE_CHOOSER_ACTION_SAVE. It cannot be set with either of the folder
405 gtk_file_chooser_set_select_multiple (GtkFileChooser *chooser,
406 gboolean select_multiple)
408 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
410 g_object_set (chooser, "select-multiple", select_multiple, NULL);
414 * gtk_file_chooser_get_select_multiple:
415 * @chooser: a #GtkFileChooser
417 * Gets whether multiple files can be selected in the file
418 * selector. See gtk_file_chooser_set_select_multiple().
420 * Return value: %TRUE if multiple files can be selected.
425 gtk_file_chooser_get_select_multiple (GtkFileChooser *chooser)
427 gboolean select_multiple;
429 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
431 g_object_get (chooser, "select-multiple", &select_multiple, NULL);
433 return select_multiple;
437 * gtk_file_chooser_get_filename:
438 * @chooser: a #GtkFileChooser
440 * Gets the filename for the currently selected file in
441 * the file selector. If multiple files are selected,
442 * one of the filenames will be returned at random.
444 * If the file chooser is in folder mode, this function returns the selected
447 * Return value: The currently selected filename, or %NULL
448 * if no file is selected, or the selected file can't
449 * be represented with a local filename. Free with g_free().
454 gtk_file_chooser_get_filename (GtkFileChooser *chooser)
456 GtkFileSystem *file_system;
458 gchar *result = NULL;
460 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
462 file_system = _gtk_file_chooser_get_file_system (chooser);
463 path = gtk_file_chooser_get_path (chooser);
466 result = gtk_file_system_path_to_filename (file_system, path);
467 gtk_file_path_free (path);
474 * gtk_file_chooser_set_filename:
475 * @chooser: a #GtkFileChooser
476 * @filename: the filename to set as current
478 * Sets @filename as the current filename for the file chooser, by changing
479 * to the file's parent folder and actually selecting the file in list. If
480 * the @chooser is in #GTK_FILE_CHOOSER_ACTION_SAVE mode, the file's base name
481 * will also appear in the dialog's file name entry.
483 * If the file name isn't in the current folder of @chooser, then the current
484 * folder of @chooser will be changed to the folder containing @filename. This
485 * is equivalent to a sequence of gtk_file_chooser_unselect_all() followed by
486 * gtk_file_chooser_select_filename().
488 * Note that the file must exist, or nothing will be done except
489 * for the directory change.
491 * If you are implementing a <guimenuitem>File/Save As...</guimenuitem> dialog, you
492 * should use this function if you already have a file name to which the user may save; for example,
493 * when the user opens an existing file and then does <guimenuitem>File/Save As...</guimenuitem>
494 * on it. If you don't have a file name already — for example, if the user just created
495 * a new file and is saving it for the first time, do not call this function. Instead, use
496 * something similar to this:
499 * if (document_is_new)
501 * /<!-- -->* the user just created a new document *<!-- -->/
502 * gtk_file_chooser_set_current_folder (chooser, default_folder_for_saving);
503 * gtk_file_chooser_set_current_name (chooser, "Untitled document");
507 * /<!-- -->* the user edited an existing document *<!-- -->/
508 * gtk_file_chooser_set_filename (chooser, existing_filename);
512 * Return value: %TRUE if both the folder could be changed and the file was
513 * selected successfully, %FALSE otherwise.
518 gtk_file_chooser_set_filename (GtkFileChooser *chooser,
519 const gchar *filename)
521 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
523 gtk_file_chooser_unselect_all (chooser);
524 return gtk_file_chooser_select_filename (chooser, filename);
528 * gtk_file_chooser_select_filename:
529 * @chooser: a #GtkFileChooser
530 * @filename: the filename to select
532 * Selects a filename. If the file name isn't in the current
533 * folder of @chooser, then the current folder of @chooser will
534 * be changed to the folder containing @filename.
536 * Return value: %TRUE if both the folder could be changed and the file was
537 * selected successfully, %FALSE otherwise.
542 gtk_file_chooser_select_filename (GtkFileChooser *chooser,
543 const gchar *filename)
545 GtkFileSystem *file_system;
549 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
550 g_return_val_if_fail (filename != NULL, FALSE);
552 file_system = _gtk_file_chooser_get_file_system (chooser);
554 path = gtk_file_system_filename_to_path (file_system, filename);
557 result = _gtk_file_chooser_select_path (chooser, path, NULL);
558 gtk_file_path_free (path);
567 * gtk_file_chooser_unselect_filename:
568 * @chooser: a #GtkFileChooser
569 * @filename: the filename to unselect
571 * Unselects a currently selected filename. If the filename
572 * is not in the current directory, does not exist, or
573 * is otherwise not currently selected, does nothing.
578 gtk_file_chooser_unselect_filename (GtkFileChooser *chooser,
579 const char *filename)
581 GtkFileSystem *file_system;
584 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
585 g_return_if_fail (filename != NULL);
587 file_system = _gtk_file_chooser_get_file_system (chooser);
589 path = gtk_file_system_filename_to_path (file_system, filename);
592 _gtk_file_chooser_unselect_path (chooser, path);
593 gtk_file_path_free (path);
597 /* Converts a list of GtkFilePath* to a list of strings using the specified function */
599 file_paths_to_strings (GtkFileSystem *fs,
601 gchar * (*convert_func) (GtkFileSystem *fs, const GtkFilePath *path))
607 for (; paths; paths = paths->next)
613 string = (* convert_func) (fs, path);
616 strings = g_slist_prepend (strings, string);
619 return g_slist_reverse (strings);
623 * gtk_file_chooser_get_filenames:
624 * @chooser: a #GtkFileChooser
626 * Lists all the selected files and subfolders in the current folder of
627 * @chooser. The returned names are full absolute paths. If files in the current
628 * folder cannot be represented as local filenames they will be ignored. (See
629 * gtk_file_chooser_get_uris())
631 * Return value: a #GSList containing the filenames of all selected
632 * files and subfolders in the current folder. Free the returned list
633 * with g_slist_free(), and the filenames with g_free().
638 gtk_file_chooser_get_filenames (GtkFileChooser *chooser)
640 GtkFileSystem *file_system;
644 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
646 file_system = _gtk_file_chooser_get_file_system (chooser);
647 paths = _gtk_file_chooser_get_paths (chooser);
649 result = file_paths_to_strings (file_system, paths, gtk_file_system_path_to_filename);
650 gtk_file_paths_free (paths);
655 * gtk_file_chooser_set_current_folder:
656 * @chooser: a #GtkFileChooser
657 * @filename: the full path of the new current folder
659 * Sets the current folder for @chooser from a local filename.
660 * The user will be shown the full contents of the current folder,
661 * plus user interface elements for navigating to other folders.
663 * Return value: %TRUE if the folder could be changed successfully, %FALSE
669 gtk_file_chooser_set_current_folder (GtkFileChooser *chooser,
670 const gchar *filename)
672 GtkFileSystem *file_system;
676 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
677 g_return_val_if_fail (filename != NULL, FALSE);
679 file_system = _gtk_file_chooser_get_file_system (chooser);
681 path = gtk_file_system_filename_to_path (file_system, filename);
684 result = _gtk_file_chooser_set_current_folder_path (chooser, path, NULL);
685 gtk_file_path_free (path);
694 * gtk_file_chooser_get_current_folder:
695 * @chooser: a #GtkFileChooser
697 * Gets the current folder of @chooser as a local filename.
698 * See gtk_file_chooser_set_current_folder().
700 * Return value: the full path of the current folder, or %NULL if the current
701 * path cannot be represented as a local filename. Free with g_free(). This
702 * function will also return %NULL if the file chooser was unable to load the
703 * last folder that was requested from it; for example, as would be for calling
704 * gtk_file_chooser_set_current_folder() on a nonexistent folder.
709 gtk_file_chooser_get_current_folder (GtkFileChooser *chooser)
711 GtkFileSystem *file_system;
715 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
717 file_system = _gtk_file_chooser_get_file_system (chooser);
719 path = _gtk_file_chooser_get_current_folder_path (chooser);
720 filename = gtk_file_system_path_to_filename (file_system, path);
721 gtk_file_path_free (path);
727 * gtk_file_chooser_set_current_name:
728 * @chooser: a #GtkFileChooser
729 * @name: the filename to use, as a UTF-8 string
731 * Sets the current name in the file selector, as if entered
732 * by the user. Note that the name passed in here is a UTF-8
733 * string rather than a filename. This function is meant for
734 * such uses as a suggested name in a "Save As..." dialog.
736 * If you want to preselect a particular existing file, you should use
737 * gtk_file_chooser_set_filename() or gtk_file_chooser_set_uri() instead.
738 * Please see the documentation for those functions for an example of using
739 * gtk_file_chooser_set_current_name() as well.
744 gtk_file_chooser_set_current_name (GtkFileChooser *chooser,
747 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
748 g_return_if_fail (name != NULL);
750 GTK_FILE_CHOOSER_GET_IFACE (chooser)->set_current_name (chooser, name);
754 * gtk_file_chooser_get_uri:
755 * @chooser: a #GtkFileChooser
757 * Gets the URI for the currently selected file in
758 * the file selector. If multiple files are selected,
759 * one of the filenames will be returned at random.
761 * If the file chooser is in folder mode, this function returns the selected
764 * Return value: The currently selected URI, or %NULL
765 * if no file is selected. Free with g_free()
770 gtk_file_chooser_get_uri (GtkFileChooser *chooser)
772 GtkFileSystem *file_system;
774 gchar *result = NULL;
776 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
778 file_system = _gtk_file_chooser_get_file_system (chooser);
779 path = gtk_file_chooser_get_path (chooser);
782 result = gtk_file_system_path_to_uri (file_system, path);
783 gtk_file_path_free (path);
790 * gtk_file_chooser_set_uri:
791 * @chooser: a #GtkFileChooser
792 * @uri: the URI to set as current
794 * Sets the file referred to by @uri as the current file for the file chooser,
795 * by changing to the URI's parent folder and actually selecting the URI in the
796 * list. If the @chooser is #GTK_FILE_CHOOSER_ACTION_SAVE mode, the URI's base
797 * name will also appear in the dialog's file name entry.
799 * If the URI isn't in the current folder of @chooser, then the current folder
800 * of @chooser will be changed to the folder containing @uri. This is equivalent
801 * to a sequence of gtk_file_chooser_unselect_all() followed by
802 * gtk_file_chooser_select_uri().
804 * Note that the URI must exist, or nothing will be done except
805 * for the directory change.
806 * If you are implementing a <guimenuitem>File/Save As...</guimenuitem> dialog, you
807 * should use this function if you already have a file name to which the user may save; for example,
808 * when the user opens an existing file and then does <guimenuitem>File/Save As...</guimenuitem>
809 * on it. If you don't have a file name already — for example, if the user just created
810 * a new file and is saving it for the first time, do not call this function. Instead, use
811 * something similar to this:
814 * if (document_is_new)
816 * /<!-- -->* the user just created a new document *<!-- -->/
817 * gtk_file_chooser_set_current_folder_uri (chooser, default_folder_for_saving);
818 * gtk_file_chooser_set_current_name (chooser, "Untitled document");
822 * /<!-- -->* the user edited an existing document *<!-- -->/
823 * gtk_file_chooser_set_uri (chooser, existing_uri);
827 * Return value: %TRUE if both the folder could be changed and the URI was
828 * selected successfully, %FALSE otherwise.
833 gtk_file_chooser_set_uri (GtkFileChooser *chooser,
836 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
838 gtk_file_chooser_unselect_all (chooser);
839 return gtk_file_chooser_select_uri (chooser, uri);
843 * gtk_file_chooser_select_uri:
844 * @chooser: a #GtkFileChooser
845 * @uri: the URI to select
847 * Selects the file to by @uri. If the URI doesn't refer to a
848 * file in the current folder of @chooser, then the current folder of
849 * @chooser will be changed to the folder containing @filename.
851 * Return value: %TRUE if both the folder could be changed and the URI was
852 * selected successfully, %FALSE otherwise.
857 gtk_file_chooser_select_uri (GtkFileChooser *chooser,
860 GtkFileSystem *file_system;
864 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
865 g_return_val_if_fail (uri != NULL, FALSE);
867 file_system = _gtk_file_chooser_get_file_system (chooser);
869 path = gtk_file_system_uri_to_path (file_system, uri);
872 result = _gtk_file_chooser_select_path (chooser, path, NULL);
873 gtk_file_path_free (path);
882 * gtk_file_chooser_unselect_uri:
883 * @chooser: a #GtkFileChooser
884 * @uri: the URI to unselect
886 * Unselects the file referred to by @uri. If the file
887 * is not in the current directory, does not exist, or
888 * is otherwise not currently selected, does nothing.
893 gtk_file_chooser_unselect_uri (GtkFileChooser *chooser,
896 GtkFileSystem *file_system;
899 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
900 g_return_if_fail (uri != NULL);
902 file_system = _gtk_file_chooser_get_file_system (chooser);
904 path = gtk_file_system_uri_to_path (file_system, uri);
907 _gtk_file_chooser_unselect_path (chooser, path);
908 gtk_file_path_free (path);
913 * gtk_file_chooser_select_all:
914 * @chooser: a #GtkFileChooser
916 * Selects all the files in the current folder of a file chooser.
921 gtk_file_chooser_select_all (GtkFileChooser *chooser)
923 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
925 GTK_FILE_CHOOSER_GET_IFACE (chooser)->select_all (chooser);
929 * gtk_file_chooser_unselect_all:
930 * @chooser: a #GtkFileChooser
932 * Unselects all the files in the current folder of a file chooser.
937 gtk_file_chooser_unselect_all (GtkFileChooser *chooser)
940 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
942 GTK_FILE_CHOOSER_GET_IFACE (chooser)->unselect_all (chooser);
946 * gtk_file_chooser_get_uris:
947 * @chooser: a #GtkFileChooser
949 * Lists all the selected files and subfolders in the current folder of
950 * @chooser. The returned names are full absolute URIs.
952 * Return value: a #GSList containing the URIs of all selected
953 * files and subfolders in the current folder. Free the returned list
954 * with g_slist_free(), and the filenames with g_free().
959 gtk_file_chooser_get_uris (GtkFileChooser *chooser)
961 GtkFileSystem *file_system;
965 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
967 file_system = _gtk_file_chooser_get_file_system (chooser);
968 paths = _gtk_file_chooser_get_paths (chooser);
970 result = file_paths_to_strings (file_system, paths, gtk_file_system_path_to_uri);
971 gtk_file_paths_free (paths);
976 * gtk_file_chooser_set_current_folder_uri:
977 * @chooser: a #GtkFileChooser
978 * @uri: the URI for the new current folder
980 * Sets the current folder for @chooser from an URI.
981 * The user will be shown the full contents of the current folder,
982 * plus user interface elements for navigating to other folders.
984 * Return value: %TRUE if the folder could be changed successfully, %FALSE
990 gtk_file_chooser_set_current_folder_uri (GtkFileChooser *chooser,
993 GtkFileSystem *file_system;
997 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
998 g_return_val_if_fail (uri != NULL, FALSE);
1000 file_system = _gtk_file_chooser_get_file_system (chooser);
1002 path = gtk_file_system_uri_to_path (file_system, uri);
1005 result = _gtk_file_chooser_set_current_folder_path (chooser, path, NULL);
1006 gtk_file_path_free (path);
1015 * gtk_file_chooser_get_current_folder_uri:
1016 * @chooser: a #GtkFileChooser
1018 * Gets the current folder of @chooser as an URI.
1019 * See gtk_file_chooser_set_current_folder_uri().
1021 * Return value: the URI for the current folder. Free with g_free(). This
1022 * function will also return %NULL if the file chooser was unable to load the
1023 * last folder that was requested from it; for example, as would be for calling
1024 * gtk_file_chooser_set_current_folder_uri() on a nonexistent folder.
1029 gtk_file_chooser_get_current_folder_uri (GtkFileChooser *chooser)
1031 GtkFileSystem *file_system;
1035 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1037 file_system = _gtk_file_chooser_get_file_system (chooser);
1039 path = _gtk_file_chooser_get_current_folder_path (chooser);
1040 uri = gtk_file_system_path_to_uri (file_system, path);
1041 gtk_file_path_free (path);
1047 * _gtk_file_chooser_set_current_folder_path:
1048 * @chooser: a #GtkFileChooser
1049 * @path: the #GtkFilePath for the new folder
1050 * @error: location to store error, or %NULL.
1052 * Sets the current folder for @chooser from a #GtkFilePath.
1053 * Internal function, see gtk_file_chooser_set_current_folder_uri().
1055 * Return value: %TRUE if the folder could be changed successfully, %FALSE
1061 _gtk_file_chooser_set_current_folder_path (GtkFileChooser *chooser,
1062 const GtkFilePath *path,
1065 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1066 g_return_val_if_fail (path != NULL, FALSE);
1067 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
1069 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->set_current_folder (chooser, path, error);
1073 * _gtk_file_chooser_get_current_folder_path:
1074 * @chooser: a #GtkFileChooser
1076 * Gets the current folder of @chooser as #GtkFilePath.
1077 * See gtk_file_chooser_get_current_folder_uri().
1079 * Return value: the #GtkFilePath for the current folder.
1080 * Free with gtk_file_path_free().
1085 _gtk_file_chooser_get_current_folder_path (GtkFileChooser *chooser)
1087 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1089 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_current_folder (chooser);
1093 * _gtk_file_chooser_select_path:
1094 * @chooser: a #GtkFileChooser
1095 * @path: the path to select
1096 * @error: location to store error, or %NULL
1098 * Selects the file referred to by @path. An internal function. See
1099 * _gtk_file_chooser_select_uri().
1101 * Return value: %TRUE if both the folder could be changed and the path was
1102 * selected successfully, %FALSE otherwise.
1107 _gtk_file_chooser_select_path (GtkFileChooser *chooser,
1108 const GtkFilePath *path,
1111 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1112 g_return_val_if_fail (path != NULL, FALSE);
1113 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
1115 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->select_path (chooser, path, error);
1119 * _gtk_file_chooser_unselect_path:
1120 * @chooser: a #GtkFileChooser
1121 * @path: the filename to path
1123 * Unselects the file referred to by @path. An internal
1124 * function. See _gtk_file_chooser_unselect_uri().
1129 _gtk_file_chooser_unselect_path (GtkFileChooser *chooser,
1130 const GtkFilePath *path)
1132 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1134 GTK_FILE_CHOOSER_GET_IFACE (chooser)->unselect_path (chooser, path);
1138 * _gtk_file_chooser_get_paths:
1139 * @chooser: a #GtkFileChooser
1141 * Lists all the selected files and subfolders in the current folder of @chooser
1142 * as #GtkFilePath. An internal function, see gtk_file_chooser_get_uris().
1144 * Return value: a #GSList containing a #GtkFilePath for each selected
1145 * file and subfolder in the current folder. Free the returned list
1146 * with g_slist_free(), and the paths with gtk_file_path_free().
1151 _gtk_file_chooser_get_paths (GtkFileChooser *chooser)
1153 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1155 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_paths (chooser);
1158 static GtkFilePath *
1159 gtk_file_chooser_get_path (GtkFileChooser *chooser)
1162 GtkFilePath *result = NULL;
1164 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1166 list = _gtk_file_chooser_get_paths (chooser);
1169 result = list->data;
1170 list = g_slist_delete_link (list, list);
1171 gtk_file_paths_free (list);
1178 * _gtk_file_chooser_get_file_system:
1179 * @chooser: a #GtkFileChooser
1181 * Gets the #GtkFileSystem of @chooser; this is an internal
1182 * implementation detail, used for conversion between paths
1183 * and filenames and URIs.
1185 * Return value: the file system for @chooser.
1190 _gtk_file_chooser_get_file_system (GtkFileChooser *chooser)
1192 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1194 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_file_system (chooser);
1200 * gtk_file_chooser_set_preview_widget:
1201 * @chooser: a #GtkFileChooser
1202 * @preview_widget: widget for displaying preview.
1204 * Sets an application-supplied widget to use to display a custom preview
1205 * of the currently selected file. To implement a preview, after setting the
1206 * preview widget, you connect to the ::update-preview
1207 * signal, and call gtk_file_chooser_get_preview_filename() or
1208 * gtk_file_chooser_get_preview_uri() on each change. If you can
1209 * display a preview of the new file, update your widget and
1210 * set the preview active using gtk_file_chooser_set_preview_widget_active().
1211 * Otherwise, set the preview inactive.
1213 * When there is no application-supplied preview widget, or the
1214 * application-supplied preview widget is not active, the file chooser
1215 * may display an internally generated preview of the current file or
1216 * it may display no preview at all.
1221 gtk_file_chooser_set_preview_widget (GtkFileChooser *chooser,
1222 GtkWidget *preview_widget)
1224 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1226 g_object_set (chooser, "preview-widget", preview_widget, NULL);
1230 * gtk_file_chooser_get_preview_widget:
1231 * @chooser: a #GtkFileChooser
1233 * Gets the current preview widget; see
1234 * gtk_file_chooser_set_preview_widget().
1236 * Return value: the current preview widget, or %NULL
1241 gtk_file_chooser_get_preview_widget (GtkFileChooser *chooser)
1243 GtkWidget *preview_widget;
1245 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1247 g_object_get (chooser, "preview-widget", &preview_widget, NULL);
1249 /* Horrid hack; g_object_get() refs returned objects but
1250 * that contradicts the memory management conventions
1254 g_object_unref (preview_widget);
1256 return preview_widget;
1260 * gtk_file_chooser_set_preview_widget_active:
1261 * @chooser: a #GtkFileChooser
1262 * @active: whether to display the user-specified preview widget
1264 * Sets whether the preview widget set by
1265 * gtk_file_chooser_set_preview_widget() should be shown for the
1266 * current filename. When @active is set to false, the file chooser
1267 * may display an internally generated preview of the current file
1268 * or it may display no preview at all. See
1269 * gtk_file_chooser_set_preview_widget() for more details.
1274 gtk_file_chooser_set_preview_widget_active (GtkFileChooser *chooser,
1277 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1279 g_object_set (chooser, "preview-widget-active", active, NULL);
1283 * gtk_file_chooser_get_preview_widget_active:
1284 * @chooser: a #GtkFileChooser
1286 * Gets whether the preview widget set by gtk_file_chooser_set_preview_widget()
1287 * should be shown for the current filename. See
1288 * gtk_file_chooser_set_preview_widget_active().
1290 * Return value: %TRUE if the preview widget is active for the current filename.
1295 gtk_file_chooser_get_preview_widget_active (GtkFileChooser *chooser)
1299 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1301 g_object_get (chooser, "preview-widget-active", &active, NULL);
1307 * gtk_file_chooser_set_use_preview_label:
1308 * @chooser: a #GtkFileChooser
1309 * @use_label: whether to display a stock label with the name of the previewed file
1311 * Sets whether the file chooser should display a stock label with the name of
1312 * the file that is being previewed; the default is %TRUE. Applications that
1313 * want to draw the whole preview area themselves should set this to %FALSE and
1314 * display the name themselves in their preview widget.
1316 * See also: gtk_file_chooser_set_preview_widget()
1321 gtk_file_chooser_set_use_preview_label (GtkFileChooser *chooser,
1324 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1326 g_object_set (chooser, "use-preview-label", use_label, NULL);
1330 * gtk_file_chooser_get_use_preview_label:
1331 * @chooser: a #GtkFileChooser
1333 * Gets whether a stock label should be drawn with the name of the previewed
1334 * file. See gtk_file_chooser_set_use_preview_label().
1336 * Return value: %TRUE if the file chooser is set to display a label with the
1337 * name of the previewed file, %FALSE otherwise.
1340 gtk_file_chooser_get_use_preview_label (GtkFileChooser *chooser)
1344 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1346 g_object_get (chooser, "use-preview-label", &use_label, NULL);
1352 * gtk_file_chooser_get_preview_filename:
1353 * @chooser: a #GtkFileChooser
1355 * Gets the filename that should be previewed in a custom preview
1356 * Internal function, see gtk_file_chooser_get_preview_uri().
1358 * Return value: the #GtkFilePath for the file to preview, or %NULL if no file
1359 * is selected. Free with gtk_file_path_free().
1364 _gtk_file_chooser_get_preview_path (GtkFileChooser *chooser)
1366 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1368 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_preview_path (chooser);
1372 * _gtk_file_chooser_add_shortcut_folder:
1373 * @chooser: a #GtkFileChooser
1374 * @path: path of the folder to add
1375 * @error: location to store error, or %NULL
1377 * Adds a folder to be displayed with the shortcut folders in a file chooser.
1378 * Internal function, see gtk_file_chooser_add_shortcut_folder().
1380 * Return value: %TRUE if the folder could be added successfully, %FALSE
1386 _gtk_file_chooser_add_shortcut_folder (GtkFileChooser *chooser,
1387 const GtkFilePath *path,
1390 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1391 g_return_val_if_fail (path != NULL, FALSE);
1393 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_shortcut_folder (chooser, path, error);
1397 * _gtk_file_chooser_remove_shortcut_folder:
1398 * @chooser: a #GtkFileChooser
1399 * @path: path of the folder to remove
1400 * @error: location to store error, or %NULL
1402 * Removes a folder from the shortcut folders in a file chooser. Internal
1403 * function, see gtk_file_chooser_remove_shortcut_folder().
1405 * Return value: %TRUE if the folder could be removed successfully, %FALSE
1411 _gtk_file_chooser_remove_shortcut_folder (GtkFileChooser *chooser,
1412 const GtkFilePath *path,
1415 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1416 g_return_val_if_fail (path != NULL, FALSE);
1418 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_shortcut_folder (chooser, path, error);
1422 * gtk_file_chooser_get_preview_filename:
1423 * @chooser: a #GtkFileChooser
1425 * Gets the filename that should be previewed in a custom preview
1426 * widget. See gtk_file_chooser_set_preview_widget().
1428 * Return value: the filename to preview, or %NULL if no file
1429 * is selected, or if the selected file cannot be represented
1430 * as a local filename. Free with g_free()
1435 gtk_file_chooser_get_preview_filename (GtkFileChooser *chooser)
1437 GtkFileSystem *file_system;
1439 gchar *result = NULL;
1441 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1443 file_system = _gtk_file_chooser_get_file_system (chooser);
1444 path = _gtk_file_chooser_get_preview_path (chooser);
1447 result = gtk_file_system_path_to_filename (file_system, path);
1448 gtk_file_path_free (path);
1455 * gtk_file_chooser_get_preview_uri:
1456 * @chooser: a #GtkFileChooser
1458 * Gets the URI that should be previewed in a custom preview
1459 * widget. See gtk_file_chooser_set_preview_widget().
1461 * Return value: the URI for the file to preview, or %NULL if no file is
1462 * selected. Free with g_free().
1467 gtk_file_chooser_get_preview_uri (GtkFileChooser *chooser)
1469 GtkFileSystem *file_system;
1471 gchar *result = NULL;
1473 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1475 file_system = _gtk_file_chooser_get_file_system (chooser);
1476 path = _gtk_file_chooser_get_preview_path (chooser);
1479 result = gtk_file_system_path_to_uri (file_system, path);
1480 gtk_file_path_free (path);
1487 * gtk_file_chooser_set_extra_widget:
1488 * @chooser: a #GtkFileChooser
1489 * @extra_widget: widget for extra options
1491 * Sets an application-supplied widget to provide extra options to the user.
1496 gtk_file_chooser_set_extra_widget (GtkFileChooser *chooser,
1497 GtkWidget *extra_widget)
1499 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1501 g_object_set (chooser, "extra-widget", extra_widget, NULL);
1505 * gtk_file_chooser_get_extra_widget:
1506 * @chooser: a #GtkFileChooser
1508 * Gets the current preview widget; see
1509 * gtk_file_chooser_set_extra_widget().
1511 * Return value: the current extra widget, or %NULL
1516 gtk_file_chooser_get_extra_widget (GtkFileChooser *chooser)
1518 GtkWidget *extra_widget;
1520 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1522 g_object_get (chooser, "extra-widget", &extra_widget, NULL);
1524 /* Horrid hack; g_object_get() refs returned objects but
1525 * that contradicts the memory management conventions
1529 g_object_unref (extra_widget);
1531 return extra_widget;
1535 * gtk_file_chooser_add_filter:
1536 * @chooser: a #GtkFileChooser
1537 * @filter: a #GtkFileFilter
1539 * Adds @filter to the list of filters that the user can select between.
1540 * When a filter is selected, only files that are passed by that
1541 * filter are displayed.
1543 * Note that the @chooser takes ownership of the filter, so you have to
1544 * ref and sink it if you want to keep a reference.
1549 gtk_file_chooser_add_filter (GtkFileChooser *chooser,
1550 GtkFileFilter *filter)
1552 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1554 GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_filter (chooser, filter);
1558 * gtk_file_chooser_remove_filter:
1559 * @chooser: a #GtkFileChooser
1560 * @filter: a #GtkFileFilter
1562 * Removes @filter from the list of filters that the user can select between.
1567 gtk_file_chooser_remove_filter (GtkFileChooser *chooser,
1568 GtkFileFilter *filter)
1570 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1572 GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_filter (chooser, filter);
1576 * gtk_file_chooser_list_filters:
1577 * @chooser: a #GtkFileChooser
1579 * Lists the current set of user-selectable filters; see
1580 * gtk_file_chooser_add_filter(), gtk_file_chooser_remove_filter().
1582 * Return value: a #GSList containing the current set of
1583 * user selectable filters. The contents of the list are
1584 * owned by GTK+, but you must free the list itself with
1585 * g_slist_free() when you are done with it.
1590 gtk_file_chooser_list_filters (GtkFileChooser *chooser)
1592 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1594 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->list_filters (chooser);
1598 * gtk_file_chooser_set_filter:
1599 * @chooser: a #GtkFileChooser
1600 * @filter: a #GtkFileFilter
1602 * Sets the current filter; only the files that pass the
1603 * filter will be displayed. If the user-selectable list of filters
1604 * is non-empty, then the filter should be one of the filters
1605 * in that list. Setting the current filter when the list of
1606 * filters is empty is useful if you want to restrict the displayed
1607 * set of files without letting the user change it.
1612 gtk_file_chooser_set_filter (GtkFileChooser *chooser,
1613 GtkFileFilter *filter)
1615 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1616 g_return_if_fail (GTK_IS_FILE_FILTER (filter));
1618 g_object_set (chooser, "filter", filter, NULL);
1622 * gtk_file_chooser_get_filter:
1623 * @chooser: a #GtkFileChooser
1625 * Gets the current filter; see gtk_file_chooser_set_filter().
1627 * Return value: the current filter, or %NULL
1632 gtk_file_chooser_get_filter (GtkFileChooser *chooser)
1634 GtkFileFilter *filter;
1636 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1638 g_object_get (chooser, "filter", &filter, NULL);
1639 /* Horrid hack; g_object_get() refs returned objects but
1640 * that contradicts the memory management conventions
1644 g_object_unref (filter);
1650 * gtk_file_chooser_add_shortcut_folder:
1651 * @chooser: a #GtkFileChooser
1652 * @folder: filename of the folder to add
1653 * @error: location to store error, or %NULL
1655 * Adds a folder to be displayed with the shortcut folders in a file chooser.
1656 * Note that shortcut folders do not get saved, as they are provided by the
1657 * application. For example, you can use this to add a
1658 * "/usr/share/mydrawprogram/Clipart" folder to the volume list.
1660 * Return value: %TRUE if the folder could be added successfully, %FALSE
1661 * otherwise. In the latter case, the @error will be set as appropriate.
1666 gtk_file_chooser_add_shortcut_folder (GtkFileChooser *chooser,
1673 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1674 g_return_val_if_fail (folder != NULL, FALSE);
1676 path = gtk_file_system_filename_to_path (_gtk_file_chooser_get_file_system (chooser), folder);
1680 GTK_FILE_CHOOSER_ERROR,
1681 GTK_FILE_CHOOSER_ERROR_BAD_FILENAME,
1682 _("Invalid filename: %s"),
1687 result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_shortcut_folder (chooser, path, error);
1689 gtk_file_path_free (path);
1695 * gtk_file_chooser_remove_shortcut_folder:
1696 * @chooser: a #GtkFileChooser
1697 * @folder: filename of the folder to remove
1698 * @error: location to store error, or %NULL
1700 * Removes a folder from a file chooser's list of shortcut folders.
1702 * Return value: %TRUE if the operation succeeds, %FALSE otherwise.
1703 * In the latter case, the @error will be set as appropriate.
1705 * See also: gtk_file_chooser_add_shortcut_folder()
1710 gtk_file_chooser_remove_shortcut_folder (GtkFileChooser *chooser,
1717 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1718 g_return_val_if_fail (folder != NULL, FALSE);
1720 path = gtk_file_system_filename_to_path (_gtk_file_chooser_get_file_system (chooser), folder);
1724 GTK_FILE_CHOOSER_ERROR,
1725 GTK_FILE_CHOOSER_ERROR_BAD_FILENAME,
1726 _("Invalid filename: %s"),
1731 result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_shortcut_folder (chooser, path, error);
1733 gtk_file_path_free (path);
1739 * gtk_file_chooser_list_shortcut_folders:
1740 * @chooser: a #GtkFileChooser
1742 * Queries the list of shortcut folders in the file chooser, as set by
1743 * gtk_file_chooser_add_shortcut_folder().
1745 * Return value: A list of folder filenames, or %NULL if there are no shortcut
1746 * folders. Free the returned list with g_slist_free(), and the filenames with
1752 gtk_file_chooser_list_shortcut_folders (GtkFileChooser *chooser)
1757 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1759 folders = GTK_FILE_CHOOSER_GET_IFACE (chooser)->list_shortcut_folders (chooser);
1761 result = file_paths_to_strings (_gtk_file_chooser_get_file_system (chooser),
1763 gtk_file_system_path_to_filename);
1764 gtk_file_paths_free (folders);
1769 * gtk_file_chooser_add_shortcut_folder_uri:
1770 * @chooser: a #GtkFileChooser
1771 * @uri: URI of the folder to add
1772 * @error: location to store error, or %NULL
1774 * Adds a folder URI to be displayed with the shortcut folders in a file
1775 * chooser. Note that shortcut folders do not get saved, as they are provided
1776 * by the application. For example, you can use this to add a
1777 * "file:///usr/share/mydrawprogram/Clipart" folder to the volume list.
1779 * Return value: %TRUE if the folder could be added successfully, %FALSE
1780 * otherwise. In the latter case, the @error will be set as appropriate.
1785 gtk_file_chooser_add_shortcut_folder_uri (GtkFileChooser *chooser,
1792 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1793 g_return_val_if_fail (uri != NULL, FALSE);
1795 path = gtk_file_system_uri_to_path (_gtk_file_chooser_get_file_system (chooser), uri);
1799 GTK_FILE_CHOOSER_ERROR,
1800 GTK_FILE_CHOOSER_ERROR_BAD_FILENAME,
1801 _("Invalid filename: %s"),
1806 result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_shortcut_folder (chooser, path, error);
1808 gtk_file_path_free (path);
1814 * gtk_file_chooser_remove_shortcut_folder_uri:
1815 * @chooser: a #GtkFileChooser
1816 * @uri: URI of the folder to remove
1817 * @error: location to store error, or %NULL
1819 * Removes a folder URI from a file chooser's list of shortcut folders.
1821 * Return value: %TRUE if the operation succeeds, %FALSE otherwise.
1822 * In the latter case, the @error will be set as appropriate.
1824 * See also: gtk_file_chooser_add_shortcut_folder_uri()
1829 gtk_file_chooser_remove_shortcut_folder_uri (GtkFileChooser *chooser,
1836 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1837 g_return_val_if_fail (uri != NULL, FALSE);
1839 path = gtk_file_system_uri_to_path (_gtk_file_chooser_get_file_system (chooser), uri);
1843 GTK_FILE_CHOOSER_ERROR,
1844 GTK_FILE_CHOOSER_ERROR_BAD_FILENAME,
1845 _("Invalid filename: %s"),
1850 result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_shortcut_folder (chooser, path, error);
1852 gtk_file_path_free (path);
1858 * gtk_file_chooser_list_shortcut_folder_uris:
1859 * @chooser: a #GtkFileChooser
1861 * Queries the list of shortcut folders in the file chooser, as set by
1862 * gtk_file_chooser_add_shortcut_folder_uri().
1864 * Return value: A list of folder URIs, or %NULL if there are no shortcut
1865 * folders. Free the returned list with g_slist_free(), and the URIs with
1871 gtk_file_chooser_list_shortcut_folder_uris (GtkFileChooser *chooser)
1876 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1878 folders = GTK_FILE_CHOOSER_GET_IFACE (chooser)->list_shortcut_folders (chooser);
1880 result = file_paths_to_strings (_gtk_file_chooser_get_file_system (chooser),
1882 gtk_file_system_path_to_uri);
1883 gtk_file_paths_free (folders);
1889 * gtk_file_chooser_set_show_hidden:
1890 * @chooser: a #GtkFileChooser
1891 * @show_hidden: %TRUE if hidden files and folders should be displayed.
1893 * Sets whether hidden files and folders are displayed in the file selector.
1898 gtk_file_chooser_set_show_hidden (GtkFileChooser *chooser,
1899 gboolean show_hidden)
1901 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1903 g_object_set (chooser, "show-hidden", show_hidden, NULL);
1907 * gtk_file_chooser_get_show_hidden:
1908 * @chooser: a #GtkFileChooser
1910 * Gets whether hidden files and folders are displayed in the file selector.
1911 * See gtk_file_chooser_set_show_hidden().
1913 * Return value: %TRUE if hidden files and folders are displayed.
1918 gtk_file_chooser_get_show_hidden (GtkFileChooser *chooser)
1920 gboolean show_hidden;
1922 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1924 g_object_get (chooser, "show-hidden", &show_hidden, NULL);
1930 * gtk_file_chooser_set_do_overwrite_confirmation:
1931 * @chooser: a #GtkFileChooser
1932 * @do_overwrite_confirmation: whether to confirm overwriting in save mode
1934 * Sets whether a file chooser in GTK_FILE_CHOOSER_ACTION_SAVE mode will present
1935 * a confirmation dialog if the user types a file name that already exists. This
1936 * is %FALSE by default.
1938 * Regardless of this setting, the @chooser will emit the "confirm-overwrite"
1939 * signal when appropriate.
1941 * If all you need is the stock confirmation dialog, set this property to %TRUE.
1942 * You can override the way confirmation is done by actually handling the
1943 * "confirm-overwrite" signal; please refer to its documentation for the
1949 gtk_file_chooser_set_do_overwrite_confirmation (GtkFileChooser *chooser,
1950 gboolean do_overwrite_confirmation)
1952 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1954 g_object_set (chooser, "do-overwrite-confirmation", do_overwrite_confirmation, NULL);
1958 * gtk_file_chooser_get_do_overwrite_confirmation:
1959 * @chooser: a #GtkFileChooser
1961 * Queries whether a file chooser is set to confirm for overwriting when the user
1962 * types a file name that already exists.
1964 * Return value: %TRUE if the file chooser will present a confirmation dialog;
1970 gtk_file_chooser_get_do_overwrite_confirmation (GtkFileChooser *chooser)
1972 gboolean do_overwrite_confirmation;
1974 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1976 g_object_get (chooser, "do-overwrite-confirmation", &do_overwrite_confirmation, NULL);
1978 return do_overwrite_confirmation;
1983 /* DLL ABI stability backward compatibility versions */
1985 #undef gtk_file_chooser_get_filename
1988 gtk_file_chooser_get_filename (GtkFileChooser *chooser)
1990 gchar *utf8_filename = gtk_file_chooser_get_filename_utf8 (chooser);
1991 gchar *retval = g_locale_from_utf8 (utf8_filename, -1, NULL, NULL, NULL);
1993 g_free (utf8_filename);
1998 #undef gtk_file_chooser_set_filename
2001 gtk_file_chooser_set_filename (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_filename_utf8 (chooser, utf8_filename);
2007 g_free (utf8_filename);
2012 #undef gtk_file_chooser_select_filename
2015 gtk_file_chooser_select_filename (GtkFileChooser *chooser,
2016 const gchar *filename)
2018 gchar *utf8_filename = g_locale_to_utf8 (filename, -1, NULL, NULL, NULL);
2019 gboolean retval = gtk_file_chooser_select_filename_utf8 (chooser, utf8_filename);
2021 g_free (utf8_filename);
2026 #undef gtk_file_chooser_unselect_filename
2029 gtk_file_chooser_unselect_filename (GtkFileChooser *chooser,
2030 const char *filename)
2032 gchar *utf8_filename = g_locale_to_utf8 (filename, -1, NULL, NULL, NULL);
2034 gtk_file_chooser_unselect_filename_utf8 (chooser, utf8_filename);
2035 g_free (utf8_filename);
2038 #undef gtk_file_chooser_get_filenames
2041 gtk_file_chooser_get_filenames (GtkFileChooser *chooser)
2043 GSList *list = gtk_file_chooser_get_filenames_utf8 (chooser);
2044 GSList *rover = list;
2048 gchar *tem = (gchar *) rover->data;
2049 rover->data = g_locale_from_utf8 ((gchar *) rover->data, -1, NULL, NULL, NULL);
2051 rover = rover->next;
2057 #undef gtk_file_chooser_set_current_folder
2060 gtk_file_chooser_set_current_folder (GtkFileChooser *chooser,
2061 const gchar *filename)
2063 gchar *utf8_filename = g_locale_to_utf8 (filename, -1, NULL, NULL, NULL);
2064 gboolean retval = gtk_file_chooser_set_current_folder_utf8 (chooser, utf8_filename);
2066 g_free (utf8_filename);
2071 #undef gtk_file_chooser_get_current_folder
2074 gtk_file_chooser_get_current_folder (GtkFileChooser *chooser)
2076 gchar *utf8_folder = gtk_file_chooser_get_current_folder_utf8 (chooser);
2077 gchar *retval = g_locale_from_utf8 (utf8_folder, -1, NULL, NULL, NULL);
2079 g_free (utf8_folder);
2084 #undef gtk_file_chooser_get_preview_filename
2087 gtk_file_chooser_get_preview_filename (GtkFileChooser *chooser)
2089 char *utf8_filename = gtk_file_chooser_get_preview_filename_utf8 (chooser);
2090 char *retval = g_locale_from_utf8 (utf8_filename, -1, NULL, NULL, NULL);
2092 g_free (utf8_filename);
2097 #undef gtk_file_chooser_add_shortcut_folder
2100 gtk_file_chooser_add_shortcut_folder (GtkFileChooser *chooser,
2104 char *utf8_folder = g_locale_to_utf8 (folder, -1, NULL, NULL, NULL);
2106 gtk_file_chooser_add_shortcut_folder_utf8 (chooser, utf8_folder, error);
2108 g_free (utf8_folder);
2113 #undef gtk_file_chooser_remove_shortcut_folder
2116 gtk_file_chooser_remove_shortcut_folder (GtkFileChooser *chooser,
2120 char *utf8_folder = g_locale_to_utf8 (folder, -1, NULL, NULL, NULL);
2122 gtk_file_chooser_remove_shortcut_folder_utf8 (chooser, utf8_folder, error);
2124 g_free (utf8_folder);
2129 #undef gtk_file_chooser_list_shortcut_folders
2132 gtk_file_chooser_list_shortcut_folders (GtkFileChooser *chooser)
2134 GSList *list = gtk_file_chooser_list_shortcut_folders_utf8 (chooser);
2135 GSList *rover = list;
2139 gchar *tem = (gchar *) rover->data;
2140 rover->data = g_locale_from_utf8 ((gchar *) rover->data, -1, NULL, NULL, NULL);
2142 rover = rover->next;
2150 #define __GTK_FILE_CHOOSER_C__
2151 #include "gtkaliasdef.c"