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.
23 #include "gtkfilechooser.h"
24 #include "gtkfilechooserprivate.h"
25 #include "gtkfilesystem.h"
27 #include "gtktypebuiltins.h"
29 static void gtk_file_chooser_class_init (gpointer g_iface);
31 static GtkFilePath *gtk_file_chooser_get_path (GtkFileChooser *chooser);
34 gtk_file_chooser_get_type (void)
36 static GType file_chooser_type = 0;
38 if (!file_chooser_type)
40 static const GTypeInfo file_chooser_info =
42 sizeof (GtkFileChooserIface), /* class_size */
44 NULL, /* base_finalize */
45 (GClassInitFunc)gtk_file_chooser_class_init, /* class_init */
48 file_chooser_type = g_type_register_static (G_TYPE_INTERFACE,
50 &file_chooser_info, 0);
52 g_type_interface_add_prerequisite (file_chooser_type, GTK_TYPE_WIDGET);
55 return file_chooser_type;
59 gtk_file_chooser_class_init (gpointer g_iface)
61 GType iface_type = G_TYPE_FROM_INTERFACE (g_iface);
64 * GtkFileChooser::current-folder-changed
65 * @chooser: the object which received the signal.
67 * This signal is emitted when the current folder in a #GtkFileChooser
68 * changes. This can happen due to the user performing some action that
69 * changes folders, such as selecting a bookmark or visiting a folder on the
70 * file list. It can also happen as a result of calling a function to
71 * explicitly change the current folder in a file chooser.
73 * Normally you do not need to connect to this signal, unless you need to keep
74 * track of which folder a file chooser is showing.
76 * See also: gtk_file_chooser_set_current_folder(),
77 * gtk_file_chooser_get_current_folder(),
78 * gtk_file_chooser_set_current_folder_uri(),
79 * gtk_file_chooser_get_current_folder_uri().
81 g_signal_new ("current-folder-changed",
84 G_STRUCT_OFFSET (GtkFileChooserIface, current_folder_changed),
86 g_cclosure_marshal_VOID__VOID,
90 * GtkFileChooser::selection-changed
91 * @chooser: the object which received the signal.
93 * This signal is emitted when there is a change in the set of selected files
94 * in a #GtkFileChooser. This can happen when the user modifies the selection
95 * with the mouse or the keyboard, or when explicitly calling functions to
96 * change the selection.
98 * Normally you do not need to connect to this signal, as it is easier to wait
99 * for the file chooser to finish running, and then to get the list of
100 * selected files using the functions mentioned below.
102 * See also: gtk_file_chooser_select_filename(),
103 * gtk_file_chooser_unselect_filename(), gtk_file_chooser_get_filename(),
104 * gtk_file_chooser_get_filenames(), gtk_file_chooser_select_uri(),
105 * gtk_file_chooser_unselect_uri(), gtk_file_chooser_get_uri(),
106 * gtk_file_chooser_get_uris().
108 g_signal_new ("selection-changed",
111 G_STRUCT_OFFSET (GtkFileChooserIface, selection_changed),
113 g_cclosure_marshal_VOID__VOID,
117 * GtkFileChooser::update-preview
118 * @chooser: the object which received the signal.
120 * This signal is emitted when the preview in a file chooser should be
121 * regenerated. For example, this can happen when the currently selected file
122 * changes. You should use this signal if you want your file chooser to have
125 * Once you have installed a preview widget with
126 * gtk_file_chooser_set_preview_widget(), you should update it when this
127 * signal is emitted. You can use the functions
128 * gtk_file_chooser_get_preview_filename() or
129 * gtk_file_chooser_get_preview_uri() to get the name of the file to preview.
130 * Your widget may not be able to preview all kinds of files; your callback
131 * must call gtk_file_chooser_set_preview_wiget_active() to inform the file
132 * chooser about whether the preview was generated successfully or not.
134 * Please see the example code in <xref linkend="gtkfilechooser-preview"/>.
136 * See also: gtk_file_chooser_set_preview_widget(),
137 * gtk_file_chooser_set_preview_widget_active(),
138 * gtk_file_chooser_set_use_preview_label(),
139 * gtk_file_chooser_get_preview_filename(),
140 * gtk_file_chooser_get_preview_uri().
142 g_signal_new ("update-preview",
145 G_STRUCT_OFFSET (GtkFileChooserIface, update_preview),
147 g_cclosure_marshal_VOID__VOID,
151 * GtkFileChooser::file-activated
152 * @chooser: the object which received the signal.
154 * This signal is emitted when the user "activates" a file in the file
155 * chooser. This can happen by double-clicking on a file in the file list, or
156 * by pressing <keycap>Enter</keycap>.
158 * Normally you do not need to connect to this signal. It is used internally
159 * by #GtkFileChooserDialog to know when to activate the default button in the
162 * See also: gtk_file_chooser_get_filename(),
163 * gtk_file_chooser_get_filenames(), gtk_file_chooser_get_uri(),
164 * gtk_file_chooser_get_uris().
166 g_signal_new ("file-activated",
169 G_STRUCT_OFFSET (GtkFileChooserIface, file_activated),
171 g_cclosure_marshal_VOID__VOID,
174 g_object_interface_install_property (g_iface,
175 g_param_spec_enum ("action",
177 P_("The type of operation that the file selector is performing"),
178 GTK_TYPE_FILE_CHOOSER_ACTION,
179 GTK_FILE_CHOOSER_ACTION_OPEN,
181 g_object_interface_install_property (g_iface,
182 g_param_spec_string ("file-system-backend",
183 P_("File System Backend"),
184 P_("Name of file system backend to use"),
186 G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
187 g_object_interface_install_property (g_iface,
188 g_param_spec_object ("filter",
190 P_("The current filter for selecting which files are displayed"),
191 GTK_TYPE_FILE_FILTER,
193 g_object_interface_install_property (g_iface,
194 g_param_spec_boolean ("local-only",
196 P_("Whether the selected file(s) should be limited to local file: URLs"),
199 g_object_interface_install_property (g_iface,
200 g_param_spec_object ("preview-widget",
201 P_("Preview widget"),
202 P_("Application supplied widget for custom previews."),
205 g_object_interface_install_property (g_iface,
206 g_param_spec_boolean ("preview-widget-active",
207 P_("Preview Widget Active"),
208 P_("Whether the application supplied widget for custom previews should be shown."),
211 g_object_interface_install_property (g_iface,
212 g_param_spec_boolean ("use-preview-label",
213 P_("Use Preview Label"),
214 P_("Whether to display a stock label with the name of the previewed file."),
217 g_object_interface_install_property (g_iface,
218 g_param_spec_object ("extra-widget",
220 P_("Application supplied widget for extra options."),
223 g_object_interface_install_property (g_iface,
224 g_param_spec_boolean ("select-multiple",
225 P_("Select Multiple"),
226 P_("Whether to allow multiple files to be selected"),
230 g_object_interface_install_property (g_iface,
231 g_param_spec_boolean ("show-hidden",
233 P_("Whether the hidden files and folders should be displayed"),
239 * gtk_file_chooser_error_quark:
241 * Registers an error quark for #GtkFileChooser if necessary.
243 * Return value: The error quark used for #GtkFileChooser errors.
248 gtk_file_chooser_error_quark (void)
250 static GQuark quark = 0;
252 quark = g_quark_from_static_string ("gtk-file-chooser-error-quark");
257 * gtk_file_chooser_set_action:
258 * @chooser: a #GtkFileChooser
259 * @action: the action that the file selector is performing
261 * Sets the type of operation that that the chooser is performing; the
262 * user interface is adapted to suit the selected action. For example,
263 * an option to create a new folder might be shown if the action is
264 * %GTK_FILE_CHOOSER_ACTION_SAVE but not if the action is
265 * %GTK_FILE_CHOOSER_ACTION_OPEN.
270 gtk_file_chooser_set_action (GtkFileChooser *chooser,
271 GtkFileChooserAction action)
273 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
275 g_object_set (chooser, "action", action, NULL);
279 * gtk_file_chooser_get_action:
280 * @chooser: a #GtkFileChooser
282 * Gets the type of operation that the file chooser is performing; see
283 * gtk_file_chooser_set_action().
285 * Return value: the action that the file selector is performing
290 gtk_file_chooser_get_action (GtkFileChooser *chooser)
292 GtkFileChooserAction action;
294 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
296 g_object_get (chooser, "action", &action, NULL);
302 * gtk_file_chooser_set_local_only:
303 * @chooser: a #GtkFileChooser
304 * @local_only: %TRUE if only local files can be selected
306 * Sets whether only local files can be selected in the
307 * file selector. If @local_only is %TRUE (the default),
308 * then the selected file are files are guaranteed to be
309 * accessible through the operating systems native file
310 * file system and therefore the application only
311 * needs to worry about the filename functions in
312 * #GtkFileChooser, like gtk_file_chooser_get_filename(),
313 * rather than the URI functions like
314 * gtk_file_chooser_get_uri(),
319 gtk_file_chooser_set_local_only (GtkFileChooser *chooser,
322 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
324 g_object_set (chooser, "local-only", local_only, NULL);
328 * gtk_file_chooser_get_local_only:
329 * @chooser: a #GtkFileChoosre
331 * Gets whether only local files can be selected in the
332 * file selector. See gtk_file_chooser_set_local_only()
334 * Return value: %TRUE if only local files can be selected.
339 gtk_file_chooser_get_local_only (GtkFileChooser *chooser)
343 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
345 g_object_get (chooser, "local-only", &local_only, NULL);
351 * gtk_file_chooser_set_select_multiple:
352 * @chooser: a #GtkFileChooser
353 * @select_multiple: %TRUE if multiple files can be selected.
355 * Sets whether multiple files can be selected in the file selector. This is
356 * only relevant if the action is set to be GTK_FILE_CHOOSER_ACTION_OPEN or
357 * GTK_FILE_CHOOSER_ACTION_SAVE. It cannot be set with either of the folder
363 gtk_file_chooser_set_select_multiple (GtkFileChooser *chooser,
364 gboolean select_multiple)
366 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
368 g_object_set (chooser, "select-multiple", select_multiple, NULL);
372 * gtk_file_chooser_get_select_multiple:
373 * @chooser: a #GtkFileChooser
375 * Gets whether multiple files can be selected in the file
376 * selector. See gtk_file_chooser_set_select_multiple().
378 * Return value: %TRUE if multiple files can be selected.
383 gtk_file_chooser_get_select_multiple (GtkFileChooser *chooser)
385 gboolean select_multiple;
387 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
389 g_object_get (chooser, "select-multiple", &select_multiple, NULL);
391 return select_multiple;
395 * gtk_file_chooser_get_filename:
396 * @chooser: a #GtkFileChooser
398 * Gets the filename for the currently selected file in
399 * the file selector. If multiple files are selected,
400 * one of the filenames will be returned at random.
402 * If the file chooser is in folder mode, this function returns the selected
405 * Return value: The currently selected filename, or %NULL
406 * if no file is selected, or the selected file can't
407 * be represented with a local filename. Free with g_free().
412 gtk_file_chooser_get_filename (GtkFileChooser *chooser)
414 GtkFileSystem *file_system;
416 gchar *result = NULL;
418 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
420 file_system = _gtk_file_chooser_get_file_system (chooser);
421 path = gtk_file_chooser_get_path (chooser);
424 result = gtk_file_system_path_to_filename (file_system, path);
425 gtk_file_path_free (path);
432 * gtk_file_chooser_set_filename:
433 * @chooser: a #GtkFileChooser
434 * @filename: the filename to set as current
436 * Sets @filename as the current filename for the the file chooser;
437 * If the file name isn't in the current folder of @chooser, then the
438 * current folder of @chooser will be changed to the folder containing
439 * @filename. This is equivalent to a sequence of
440 * gtk_file_chooser_unselect_all() followed by gtk_file_chooser_select_filename().
442 * Note that the file must exist, or nothing will be done except
443 * for the directory change. To pre-enter a filename for the user, as in
444 * a save-as dialog, use gtk_file_chooser_set_current_name()
446 * Return value: %TRUE if both the folder could be changed and the file was
447 * selected successfully, %FALSE otherwise.
452 gtk_file_chooser_set_filename (GtkFileChooser *chooser,
453 const gchar *filename)
455 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
457 gtk_file_chooser_unselect_all (chooser);
458 return gtk_file_chooser_select_filename (chooser, filename);
462 * gtk_file_chooser_select_filename:
463 * @chooser: a #GtkFileChooser
464 * @filename: the filename to select
466 * Selects a filename. If the file name isn't in the current
467 * folder of @chooser, then the current folder of @chooser will
468 * be changed to the folder containing @filename.
470 * Return value: %TRUE if both the folder could be changed and the file was
471 * selected successfully, %FALSE otherwise.
476 gtk_file_chooser_select_filename (GtkFileChooser *chooser,
477 const gchar *filename)
479 GtkFileSystem *file_system;
483 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
484 g_return_val_if_fail (filename != NULL, FALSE);
486 file_system = _gtk_file_chooser_get_file_system (chooser);
488 path = gtk_file_system_filename_to_path (file_system, filename);
491 result = _gtk_file_chooser_select_path (chooser, path, NULL);
492 gtk_file_path_free (path);
501 * gtk_file_chooser_unselect_filename:
502 * @chooser: a #GtkFileChooser
503 * @filename: the filename to unselect
505 * Unselects a currently selected filename. If the filename
506 * is not in the current directory, does not exist, or
507 * is otherwise not currently selected, does nothing.
512 gtk_file_chooser_unselect_filename (GtkFileChooser *chooser,
513 const char *filename)
515 GtkFileSystem *file_system;
518 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
519 g_return_if_fail (filename != NULL);
521 file_system = _gtk_file_chooser_get_file_system (chooser);
523 path = gtk_file_system_filename_to_path (file_system, filename);
526 _gtk_file_chooser_unselect_path (chooser, path);
527 gtk_file_path_free (path);
531 /* Converts a list of GtkFilePath* to a list of strings using the specified function */
533 file_paths_to_strings (GtkFileSystem *fs,
535 gchar * (*convert_func) (GtkFileSystem *fs, const GtkFilePath *path))
541 for (; paths; paths = paths->next)
547 string = (* convert_func) (fs, path);
550 strings = g_slist_prepend (strings, string);
553 return g_slist_reverse (strings);
557 * gtk_file_chooser_get_filenames:
558 * @chooser: a #GtkFileChooser
560 * Lists all the selected files and subfolders in the current folder of
561 * @chooser. The returned names are full absolute paths. If files in the current
562 * folder cannot be represented as local filenames they will be ignored. (See
563 * gtk_file_chooser_get_uris())
565 * Return value: a #GSList containing the filenames of all selected
566 * files and subfolders in the current folder. Free the returned list
567 * with g_slist_free(), and the filenames with g_free().
572 gtk_file_chooser_get_filenames (GtkFileChooser *chooser)
574 GtkFileSystem *file_system;
578 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
580 file_system = _gtk_file_chooser_get_file_system (chooser);
581 paths = _gtk_file_chooser_get_paths (chooser);
583 result = file_paths_to_strings (file_system, paths, gtk_file_system_path_to_filename);
584 gtk_file_paths_free (paths);
589 * gtk_file_chooser_set_current_folder:
590 * @chooser: a #GtkFileChooser
591 * @filename: the full path of the new current folder
593 * Sets the current folder for @chooser from a local filename.
594 * The user will be shown the full contents of the current folder,
595 * plus user interface elements for navigating to other folders.
597 * Return value: %TRUE if the folder could be changed successfully, %FALSE
603 gtk_file_chooser_set_current_folder (GtkFileChooser *chooser,
604 const gchar *filename)
606 GtkFileSystem *file_system;
610 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
611 g_return_val_if_fail (filename != NULL, FALSE);
613 file_system = _gtk_file_chooser_get_file_system (chooser);
615 path = gtk_file_system_filename_to_path (file_system, filename);
618 result = _gtk_file_chooser_set_current_folder_path (chooser, path, NULL);
619 gtk_file_path_free (path);
628 * gtk_file_chooser_get_current_folder:
629 * @chooser: a #GtkFileChooser
631 * Gets the current folder of @chooser as a local filename.
632 * See gtk_file_chooser_set_current_folder().
634 * Return value: the full path of the current folder, or %NULL
635 * if the current path cannot be represented as a local filename.
636 * Free with g_free().
641 gtk_file_chooser_get_current_folder (GtkFileChooser *chooser)
643 GtkFileSystem *file_system;
647 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
649 file_system = _gtk_file_chooser_get_file_system (chooser);
651 path = _gtk_file_chooser_get_current_folder_path (chooser);
652 filename = gtk_file_system_path_to_filename (file_system, path);
653 gtk_file_path_free (path);
659 * gtk_file_chooser_set_current_name:
660 * @chooser: a #GtkFileChooser
661 * @name: the filename to use, as a UTF-8 string
663 * Sets the current name in the file selector, as if entered
664 * by the user. Note that the name passed in here is a UTF-8
665 * string rather than a filename. This function is meant for
666 * such uses as a suggested name in a "Save As..." dialog.
668 * If you want to preselect a particular existing file, you
669 * should use gtk_file_chooser_set_filename() instead.
674 gtk_file_chooser_set_current_name (GtkFileChooser *chooser,
677 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
678 g_return_if_fail (name != NULL);
680 GTK_FILE_CHOOSER_GET_IFACE (chooser)->set_current_name (chooser, name);
684 * gtk_file_chooser_get_uri:
685 * @chooser: a #GtkFileChooser
687 * Gets the URI for the currently selected file in
688 * the file selector. If multiple files are selected,
689 * one of the filenames will be returned at random.
691 * If the file chooser is in folder mode, this function returns the selected
694 * Return value: The currently selected URI, or %NULL
695 * if no file is selected. Free with g_free()
700 gtk_file_chooser_get_uri (GtkFileChooser *chooser)
702 GtkFileSystem *file_system;
704 gchar *result = NULL;
706 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
708 file_system = _gtk_file_chooser_get_file_system (chooser);
709 path = gtk_file_chooser_get_path (chooser);
712 result = gtk_file_system_path_to_uri (file_system, path);
713 gtk_file_path_free (path);
720 * gtk_file_chooser_set_uri:
721 * @chooser: a #GtkFileChooser
722 * @uri: the URI to set as current
724 * Sets the file referred to by @uri as the current file for the the
725 * file chooser; If the file name isn't in the current folder of @chooser,
726 * then the current folder of @chooser will be changed to the folder containing
727 * @uri. This is equivalent to a sequence of gtk_file_chooser_unselect_all()
728 * followed by gtk_file_chooser_select_uri().
730 * Note that the file must exist, or nothing will be done except
731 * for the directory change. To pre-enter a filename for the user, as in
732 * a save-as dialog, use gtk_file_chooser_set_current_name()
734 * Return value: %TRUE if both the folder could be changed and the URI was
735 * selected successfully, %FALSE otherwise.
740 gtk_file_chooser_set_uri (GtkFileChooser *chooser,
743 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
745 gtk_file_chooser_unselect_all (chooser);
746 return gtk_file_chooser_select_uri (chooser, uri);
750 * gtk_file_chooser_select_uri:
751 * @chooser: a #GtkFileChooser
752 * @uri: the URI to select
754 * Selects the file to by @uri. If the URI doesn't refer to a
755 * file in the current folder of @chooser, then the current folder of
756 * @chooser will be changed to the folder containing @filename.
758 * Return value: %TRUE if both the folder could be changed and the URI was
759 * selected successfully, %FALSE otherwise.
764 gtk_file_chooser_select_uri (GtkFileChooser *chooser,
767 GtkFileSystem *file_system;
771 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
772 g_return_val_if_fail (uri != NULL, FALSE);
774 file_system = _gtk_file_chooser_get_file_system (chooser);
776 path = gtk_file_system_uri_to_path (file_system, uri);
779 result = _gtk_file_chooser_select_path (chooser, path, NULL);
780 gtk_file_path_free (path);
789 * gtk_file_chooser_unselect_uri:
790 * @chooser: a #GtkFileChooser
791 * @uri: the URI to unselect
793 * Unselects the file referred to by @uri. If the file
794 * is not in the current directory, does not exist, or
795 * is otherwise not currently selected, does nothing.
800 gtk_file_chooser_unselect_uri (GtkFileChooser *chooser,
803 GtkFileSystem *file_system;
806 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
807 g_return_if_fail (uri != NULL);
809 file_system = _gtk_file_chooser_get_file_system (chooser);
811 path = gtk_file_system_uri_to_path (file_system, uri);
814 _gtk_file_chooser_unselect_path (chooser, path);
815 gtk_file_path_free (path);
820 * gtk_file_chooser_select_all:
821 * @chooser: a #GtkFileChooser
823 * Selects all the files in the current folder of a file chooser.
828 gtk_file_chooser_select_all (GtkFileChooser *chooser)
830 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
832 GTK_FILE_CHOOSER_GET_IFACE (chooser)->select_all (chooser);
836 * gtk_file_chooser_unselect_all:
837 * @chooser: a #GtkFileChooser
839 * Unselects all the files in the current folder of a file chooser.
844 gtk_file_chooser_unselect_all (GtkFileChooser *chooser)
847 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
849 GTK_FILE_CHOOSER_GET_IFACE (chooser)->unselect_all (chooser);
853 * gtk_file_chooser_get_uris:
854 * @chooser: a #GtkFileChooser
856 * Lists all the selected files and subfolders in the current folder of
857 * @chooser. The returned names are full absolute URIs.
859 * Return value: a #GSList containing the URIs of all selected
860 * files and subfolders in the current folder. Free the returned list
861 * with g_slist_free(), and the filenames with g_free().
866 gtk_file_chooser_get_uris (GtkFileChooser *chooser)
868 GtkFileSystem *file_system;
872 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
874 file_system = _gtk_file_chooser_get_file_system (chooser);
875 paths = _gtk_file_chooser_get_paths (chooser);
877 result = file_paths_to_strings (file_system, paths, gtk_file_system_path_to_uri);
878 gtk_file_paths_free (paths);
883 * gtk_file_chooser_set_current_folder_uri:
884 * @chooser: a #GtkFileChooser
885 * @uri: the URI for the new current folder
887 * Sets the current folder for @chooser from an URI.
888 * The user will be shown the full contents of the current folder,
889 * plus user interface elements for navigating to other folders.
891 * Return value: %TRUE if the folder could be changed successfully, %FALSE
897 gtk_file_chooser_set_current_folder_uri (GtkFileChooser *chooser,
900 GtkFileSystem *file_system;
904 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
905 g_return_val_if_fail (uri != NULL, FALSE);
907 file_system = _gtk_file_chooser_get_file_system (chooser);
909 path = gtk_file_system_uri_to_path (file_system, uri);
912 result = _gtk_file_chooser_set_current_folder_path (chooser, path, NULL);
913 gtk_file_path_free (path);
922 * gtk_file_chooser_get_current_folder_uri:
923 * @chooser: a #GtkFileChooser
925 * Gets the current folder of @chooser as an URI.
926 * See gtk_file_chooser_set_current_folder_uri().
928 * Return value: the URI for the current folder.
929 * Free with g_free().
934 gtk_file_chooser_get_current_folder_uri (GtkFileChooser *chooser)
936 GtkFileSystem *file_system;
940 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
942 file_system = _gtk_file_chooser_get_file_system (chooser);
944 path = _gtk_file_chooser_get_current_folder_path (chooser);
945 uri = gtk_file_system_path_to_uri (file_system, path);
946 gtk_file_path_free (path);
952 * _gtk_file_chooser_set_current_folder_path:
953 * @chooser: a #GtkFileChooser
954 * @path: the #GtkFilePath for the new folder
955 * @error: location to store error, or %NULL.
957 * Sets the current folder for @chooser from a #GtkFilePath.
958 * Internal function, see gtk_file_chooser_set_current_folder_uri().
960 * Return value: %TRUE if the folder could be changed successfully, %FALSE
966 _gtk_file_chooser_set_current_folder_path (GtkFileChooser *chooser,
967 const GtkFilePath *path,
970 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
971 g_return_val_if_fail (path != NULL, FALSE);
972 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
974 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->set_current_folder (chooser, path, error);
978 * _gtk_file_chooser_get_current_folder_path:
979 * @chooser: a #GtkFileChooser
981 * Gets the current folder of @chooser as #GtkFilePath.
982 * See gtk_file_chooser_get_current_folder_uri().
984 * Return value: the #GtkFilePath for the current folder.
985 * Free with gtk_file_path_free().
990 _gtk_file_chooser_get_current_folder_path (GtkFileChooser *chooser)
992 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
994 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_current_folder (chooser);
998 * _gtk_file_chooser_select_path:
999 * @chooser: a #GtkFileChooser
1000 * @path: the path to select
1001 * @error: location to store error, or %NULL
1003 * Selects the file referred to by @path. An internal function. See
1004 * _gtk_file_chooser_select_uri().
1006 * Return value: %TRUE if both the folder could be changed and the path was
1007 * selected successfully, %FALSE otherwise.
1012 _gtk_file_chooser_select_path (GtkFileChooser *chooser,
1013 const GtkFilePath *path,
1016 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1017 g_return_val_if_fail (path != NULL, FALSE);
1018 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
1020 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->select_path (chooser, path, error);
1024 * _gtk_file_chooser_unselect_path:
1025 * @chooser: a #GtkFileChooser
1026 * @path: the filename to path
1028 * Unselects the file referred to by @path. An internal
1029 * function. See _gtk_file_chooser_unselect_uri().
1034 _gtk_file_chooser_unselect_path (GtkFileChooser *chooser,
1035 const GtkFilePath *path)
1037 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1039 GTK_FILE_CHOOSER_GET_IFACE (chooser)->unselect_path (chooser, path);
1043 * _gtk_file_chooser_get_paths:
1044 * @chooser: a #GtkFileChooser
1046 * Lists all the selected files and subfolders in the current folder of @chooser
1047 * as #GtkFilePath. An internal function, see gtk_file_chooser_get_uris().
1049 * Return value: a #GSList containing a #GtkFilePath for each selected
1050 * file and subfolder in the current folder. Free the returned list
1051 * with g_slist_free(), and the paths with gtk_file_path_free().
1056 _gtk_file_chooser_get_paths (GtkFileChooser *chooser)
1058 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1060 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_paths (chooser);
1063 static GtkFilePath *
1064 gtk_file_chooser_get_path (GtkFileChooser *chooser)
1067 GtkFilePath *result = NULL;
1069 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1071 list = _gtk_file_chooser_get_paths (chooser);
1074 result = list->data;
1075 list = g_slist_delete_link (list, list);
1076 gtk_file_paths_free (list);
1083 * _gtk_file_chooser_get_file_system:
1084 * @chooser: a #GtkFileChooser
1086 * Gets the #GtkFileSystem of @chooser; this is an internal
1087 * implementation detail, used for conversion between paths
1088 * and filenames and URIs.
1090 * Return value: the file system for @chooser.
1095 _gtk_file_chooser_get_file_system (GtkFileChooser *chooser)
1097 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1099 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_file_system (chooser);
1105 * gtk_file_chooser_set_preview_widget:
1106 * @chooser: a #GtkFileChooser
1107 * @preview_widget: widget for displaying preview.
1109 * Sets an application-supplied widget to use to display a custom preview
1110 * of the currently selected file. To implement a preview, after setting the
1111 * preview widget, you connect to the ::update-preview
1112 * signal, and call gtk_file_chooser_get_preview_filename() or
1113 * gtk_file_chooser_get_preview_uri() on each change. If you can
1114 * display a preview of the new file, update your widget and
1115 * set the preview active using gtk_file_chooser_set_preview_widget_active().
1116 * Otherwise, set the preview inactive.
1118 * When there is no application-supplied preview widget, or the
1119 * application-supplied preview widget is not active, the file chooser
1120 * may display an internally generated preview of the current file or
1121 * it may display no preview at all.
1126 gtk_file_chooser_set_preview_widget (GtkFileChooser *chooser,
1127 GtkWidget *preview_widget)
1129 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1131 g_object_set (chooser, "preview-widget", preview_widget, NULL);
1135 * gtk_file_chooser_get_preview_widget:
1136 * @chooser: a #GtkFileChooser
1138 * Gets the current preview widget; see
1139 * gtk_file_chooser_set_preview_widget().
1141 * Return value: the current preview widget, or %NULL
1146 gtk_file_chooser_get_preview_widget (GtkFileChooser *chooser)
1148 GtkWidget *preview_widget;
1150 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1152 g_object_get (chooser, "preview-widget", &preview_widget, NULL);
1154 /* Horrid hack; g_object_get() refs returned objects but
1155 * that contradicts the memory management conventions
1159 g_object_unref (preview_widget);
1161 return preview_widget;
1165 * gtk_file_chooser_set_preview_widget_active:
1166 * @chooser: a #GtkFileChooser
1167 * @active: whether to display the user-specified preview widget
1169 * Sets whether the preview widget set by
1170 * gtk_file_chooser_set_preview_widget_active() should be shown for the
1171 * current filename. When @active is set to false, the file chooser
1172 * may display an internally generated preview of the current file
1173 * or it may display no preview at all. See
1174 * gtk_file_chooser_set_preview_widget() for more details.
1179 gtk_file_chooser_set_preview_widget_active (GtkFileChooser *chooser,
1182 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1184 g_object_set (chooser, "preview-widget-active", active, NULL);
1188 * gtk_file_chooser_get_preview_widget_active:
1189 * @chooser: a #GtkFileChooser
1191 * Gets whether the preview widget set by gtk_file_chooser_set_preview_widget()
1192 * should be shown for the current filename. See
1193 * gtk_file_chooser_set_preview_widget_active().
1195 * Return value: %TRUE if the preview widget is active for the current filename.
1200 gtk_file_chooser_get_preview_widget_active (GtkFileChooser *chooser)
1204 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1206 g_object_get (chooser, "preview-widget-active", &active, NULL);
1212 * gtk_file_chooser_set_use_preview_label:
1213 * @chooser: a #GtkFileChooser
1214 * @use_label: whether to display a stock label with the name of the previewed file
1216 * Sets whether the file chooser should display a stock label with the name of
1217 * the file that is being previewed; the default is %TRUE. Applications that
1218 * want to draw the whole preview area themselves should set this to %FALSE and
1219 * display the name themselves in their preview widget.
1221 * See also: gtk_file_chooser_set_preview_widget()
1226 gtk_file_chooser_set_use_preview_label (GtkFileChooser *chooser,
1229 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1231 g_object_set (chooser, "use-preview-label", use_label, NULL);
1235 * gtk_file_chooser_get_use_preview_label:
1236 * @chooser: a #GtkFileChooser
1238 * Gets whether a stock label should be drawn with the name of the previewed
1239 * file. See gtk_file_chooser_set_use_preview_label().
1241 * Return value: %TRUE if the file chooser is set to display a label with the
1242 * name of the previewed file, %FALSE otherwise.
1245 gtk_file_chooser_get_use_preview_label (GtkFileChooser *chooser)
1249 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1251 g_object_get (chooser, "use-preview-label", &use_label, NULL);
1257 * gtk_file_chooser_get_preview_filename:
1258 * @chooser: a #GtkFileChooser
1260 * Gets the filename that should be previewed in a custom preview
1261 * Internal function, see gtk_file_chooser_get_preview_uri().
1263 * Return value: the #GtkFilePath for the file to preview, or %NULL if no file
1264 * is selected. Free with gtk_file_path_free().
1269 _gtk_file_chooser_get_preview_path (GtkFileChooser *chooser)
1271 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1273 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_preview_path (chooser);
1277 * _gtk_file_chooser_add_shortcut_folder:
1278 * @chooser: a #GtkFileChooser
1279 * @path: path of the folder to add
1280 * @error: location to store error, or %NULL
1282 * Adds a folder to be displayed with the shortcut folders in a file chooser.
1283 * Internal function, see gtk_file_chooser_add_shortcut_folder().
1285 * Return value: %TRUE if the folder could be added successfully, %FALSE
1291 _gtk_file_chooser_add_shortcut_folder (GtkFileChooser *chooser,
1292 const GtkFilePath *path,
1295 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1296 g_return_val_if_fail (path != NULL, FALSE);
1298 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_shortcut_folder (chooser, path, error);
1302 * _gtk_file_chooser_remove_shortcut_folder:
1303 * @chooser: a #GtkFileChooser
1304 * @path: path of the folder to remove
1305 * @error: location to store error, or %NULL
1307 * Removes a folder from the shortcut folders in a file chooser. Internal
1308 * function, see gtk_file_chooser_remove_shortcut_folder().
1310 * Return value: %TRUE if the folder could be removed successfully, %FALSE
1316 _gtk_file_chooser_remove_shortcut_folder (GtkFileChooser *chooser,
1317 const GtkFilePath *path,
1320 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1321 g_return_val_if_fail (path != NULL, FALSE);
1323 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_shortcut_folder (chooser, path, error);
1327 * gtk_file_chooser_get_preview_filename:
1328 * @chooser: a #GtkFileChooser
1330 * Gets the filename that should be previewed in a custom preview
1331 * widget. See gtk_file_chooser_set_preview_widget().
1333 * Return value: the filename to preview, or %NULL if no file
1334 * is selected, or if the selected file cannot be represented
1335 * as a local filename. Free with g_free()
1340 gtk_file_chooser_get_preview_filename (GtkFileChooser *chooser)
1342 GtkFileSystem *file_system;
1344 gchar *result = NULL;
1346 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1348 file_system = _gtk_file_chooser_get_file_system (chooser);
1349 path = _gtk_file_chooser_get_preview_path (chooser);
1352 result = gtk_file_system_path_to_filename (file_system, path);
1353 gtk_file_path_free (path);
1360 * gtk_file_chooser_get_preview_uri:
1361 * @chooser: a #GtkFileChooser
1363 * Gets the URI that should be previewed in a custom preview
1364 * widget. See gtk_file_chooser_set_preview_widget().
1366 * Return value: the URI for the file to preview, or %NULL if no file is
1367 * selected. Free with g_free().
1372 gtk_file_chooser_get_preview_uri (GtkFileChooser *chooser)
1374 GtkFileSystem *file_system;
1376 gchar *result = NULL;
1378 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1380 file_system = _gtk_file_chooser_get_file_system (chooser);
1381 path = _gtk_file_chooser_get_preview_path (chooser);
1384 result = gtk_file_system_path_to_uri (file_system, path);
1385 gtk_file_path_free (path);
1392 * gtk_file_chooser_set_extra_widget:
1393 * @chooser: a #GtkFileChooser
1394 * @extra_widget: widget for extra options
1396 * Sets an application-supplied widget to provide extra options to the user.
1401 gtk_file_chooser_set_extra_widget (GtkFileChooser *chooser,
1402 GtkWidget *extra_widget)
1404 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1406 g_object_set (chooser, "extra-widget", extra_widget, NULL);
1410 * gtk_file_chooser_get_extra_widget:
1411 * @chooser: a #GtkFileChooser
1413 * Gets the current preview widget; see
1414 * gtk_file_chooser_set_extra_widget().
1416 * Return value: the current extra widget, or %NULL
1421 gtk_file_chooser_get_extra_widget (GtkFileChooser *chooser)
1423 GtkWidget *extra_widget;
1425 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1427 g_object_get (chooser, "extra-widget", &extra_widget, NULL);
1429 /* Horrid hack; g_object_get() refs returned objects but
1430 * that contradicts the memory management conventions
1434 g_object_unref (extra_widget);
1436 return extra_widget;
1440 * gtk_file_chooser_add_filter:
1441 * @chooser: a #GtkFileChooser
1442 * @filter: a #GtkFileFilter
1444 * Adds @filter to the list of filters that the user can select between.
1445 * When a filter is selected, only files that are passed by that
1446 * filter are displayed.
1451 gtk_file_chooser_add_filter (GtkFileChooser *chooser,
1452 GtkFileFilter *filter)
1454 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1456 GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_filter (chooser, filter);
1460 * gtk_file_chooser_remove_filter:
1461 * @chooser: a #GtkFileChooser
1462 * @filter: a #GtkFileFilter
1464 * Removes @filter from the list of filters that the user can select between.
1469 gtk_file_chooser_remove_filter (GtkFileChooser *chooser,
1470 GtkFileFilter *filter)
1472 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1474 GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_filter (chooser, filter);
1478 * gtk_file_chooser_list_filters:
1479 * @chooser: a #GtkFileChooser
1481 * Lists the current set of user-selectable filters; see
1482 * gtk_file_chooser_add_filter(), gtk_file_chooser_remove_filter().
1484 * Return value: a #GSList containing the current set of
1485 * user selectable filters. The contents of the list are
1486 * owned by GTK+, but you must free the list itself with
1487 * g_slist_free() when you are done with it.
1492 gtk_file_chooser_list_filters (GtkFileChooser *chooser)
1494 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1496 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->list_filters (chooser);
1500 * gtk_file_chooser_set_filter:
1501 * @chooser: a #GtkFileChooser
1502 * @filter: a #GtkFileFilter
1504 * Sets the current filter; only the files that pass the
1505 * filter will be displayed. If the user-selectable list of filters
1506 * is non-empty, then the filter should be one of the filters
1507 * in that list. Setting the current filter when the list of
1508 * filters is empty is useful if you want to restrict the displayed
1509 * set of files without letting the user change it.
1514 gtk_file_chooser_set_filter (GtkFileChooser *chooser,
1515 GtkFileFilter *filter)
1517 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1518 g_return_if_fail (GTK_IS_FILE_FILTER (filter));
1520 g_object_set (chooser, "filter", filter, NULL);
1524 * gtk_file_chooser_get_filter:
1525 * @chooser: a #GtkFileChooser
1527 * Gets the current filter; see gtk_file_chooser_set_filter().
1529 * Return value: the current filter, or %NULL
1534 gtk_file_chooser_get_filter (GtkFileChooser *chooser)
1536 GtkFileFilter *filter;
1538 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1540 g_object_get (chooser, "filter", &filter, NULL);
1541 /* Horrid hack; g_object_get() refs returned objects but
1542 * that contradicts the memory management conventions
1546 g_object_unref (filter);
1552 * gtk_file_chooser_add_shortcut_folder:
1553 * @chooser: a #GtkFileChooser
1554 * @folder: filename of the folder to add
1555 * @error: location to store error, or %NULL
1557 * Adds a folder to be displayed with the shortcut folders in a file chooser.
1558 * Note that shortcut folders do not get saved, as they are provided by the
1559 * application. For example, you can use this to add a
1560 * "/usr/share/mydrawprogram/Clipart" folder to the volume list.
1562 * Return value: %TRUE if the folder could be added successfully, %FALSE
1563 * otherwise. In the latter case, the @error will be set as appropriate.
1568 gtk_file_chooser_add_shortcut_folder (GtkFileChooser *chooser,
1575 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1576 g_return_val_if_fail (folder != NULL, FALSE);
1578 path = gtk_file_system_filename_to_path (_gtk_file_chooser_get_file_system (chooser), folder);
1582 GTK_FILE_CHOOSER_ERROR,
1583 GTK_FILE_CHOOSER_ERROR_BAD_FILENAME,
1584 _("Invalid filename: %s"),
1589 result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_shortcut_folder (chooser, path, error);
1591 gtk_file_path_free (path);
1597 * gtk_file_chooser_remove_shortcut_folder:
1598 * @chooser: a #GtkFileChooser
1599 * @folder: filename of the folder to remove
1600 * @error: location to store error, or %NULL
1602 * Removes a folder from a file chooser's list of shortcut folders.
1604 * Return value: %TRUE if the operation succeeds, %FALSE otherwise.
1605 * In the latter case, the @error will be set as appropriate.
1607 * See also: gtk_file_chooser_add_shortcut_folder()
1612 gtk_file_chooser_remove_shortcut_folder (GtkFileChooser *chooser,
1619 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1620 g_return_val_if_fail (folder != NULL, FALSE);
1622 path = gtk_file_system_filename_to_path (_gtk_file_chooser_get_file_system (chooser), folder);
1626 GTK_FILE_CHOOSER_ERROR,
1627 GTK_FILE_CHOOSER_ERROR_BAD_FILENAME,
1628 _("Invalid filename: %s"),
1633 result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_shortcut_folder (chooser, path, error);
1635 gtk_file_path_free (path);
1641 * gtk_file_chooser_list_shortcut_folders:
1642 * @chooser: a #GtkFileChooser
1644 * Queries the list of shortcut folders in the file chooser, as set by
1645 * gtk_file_chooser_add_shortcut_folder().
1647 * Return value: A list of folder filenames, or %NULL if there are no shortcut
1648 * folders. Free the returned list with g_slist_free(), and the filenames with
1654 gtk_file_chooser_list_shortcut_folders (GtkFileChooser *chooser)
1659 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1661 folders = GTK_FILE_CHOOSER_GET_IFACE (chooser)->list_shortcut_folders (chooser);
1663 result = file_paths_to_strings (_gtk_file_chooser_get_file_system (chooser),
1665 gtk_file_system_path_to_filename);
1666 gtk_file_paths_free (folders);
1671 * gtk_file_chooser_add_shortcut_folder_uri:
1672 * @chooser: a #GtkFileChooser
1673 * @uri: URI of the folder to add
1674 * @error: location to store error, or %NULL
1676 * Adds a folder URI to be displayed with the shortcut folders in a file
1677 * chooser. Note that shortcut folders do not get saved, as they are provided
1678 * by the application. For example, you can use this to add a
1679 * "file:///usr/share/mydrawprogram/Clipart" folder to the volume list.
1681 * Return value: %TRUE if the folder could be added successfully, %FALSE
1682 * otherwise. In the latter case, the @error will be set as appropriate.
1687 gtk_file_chooser_add_shortcut_folder_uri (GtkFileChooser *chooser,
1694 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1695 g_return_val_if_fail (uri != NULL, FALSE);
1697 path = gtk_file_system_uri_to_path (_gtk_file_chooser_get_file_system (chooser), uri);
1701 GTK_FILE_CHOOSER_ERROR,
1702 GTK_FILE_CHOOSER_ERROR_BAD_FILENAME,
1703 _("Invalid filename: %s"),
1708 result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_shortcut_folder (chooser, path, error);
1710 gtk_file_path_free (path);
1716 * gtk_file_chooser_remove_shortcut_folder_uri:
1717 * @chooser: a #GtkFileChooser
1718 * @uri: URI of the folder to remove
1719 * @error: location to store error, or %NULL
1721 * Removes a folder URI from a file chooser's list of shortcut folders.
1723 * Return value: %TRUE if the operation succeeds, %FALSE otherwise.
1724 * In the latter case, the @error will be set as appropriate.
1726 * See also: gtk_file_chooser_add_shortcut_folder_uri()
1731 gtk_file_chooser_remove_shortcut_folder_uri (GtkFileChooser *chooser,
1738 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1739 g_return_val_if_fail (uri != NULL, FALSE);
1741 path = gtk_file_system_filename_to_path (_gtk_file_chooser_get_file_system (chooser), uri);
1745 GTK_FILE_CHOOSER_ERROR,
1746 GTK_FILE_CHOOSER_ERROR_BAD_FILENAME,
1747 _("Invalid filename: %s"),
1752 result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_shortcut_folder (chooser, path, error);
1754 gtk_file_path_free (path);
1760 * gtk_file_chooser_list_shortcut_folder_uris:
1761 * @chooser: a #GtkFileChooser
1763 * Queries the list of shortcut folders in the file chooser, as set by
1764 * gtk_file_chooser_add_shortcut_folder_uri().
1766 * Return value: A list of folder URIs, or %NULL if there are no shortcut
1767 * folders. Free the returned list with g_slist_free(), and the URIs with
1773 gtk_file_chooser_list_shortcut_folder_uris (GtkFileChooser *chooser)
1778 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1780 folders = GTK_FILE_CHOOSER_GET_IFACE (chooser)->list_shortcut_folders (chooser);
1782 result = file_paths_to_strings (_gtk_file_chooser_get_file_system (chooser),
1784 gtk_file_system_path_to_uri);
1785 gtk_file_paths_free (folders);
1791 * gtk_file_chooser_set_show_hidden:
1792 * @chooser: a #GtkFileChooser
1793 * @show_hidden: %TRUE if hidden files and folders should be displayed.
1795 * Sets whether hidden files and folders are displayed in the file selector.
1800 gtk_file_chooser_set_show_hidden (GtkFileChooser *chooser,
1801 gboolean show_hidden)
1803 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1805 g_object_set (chooser, "show-hidden", show_hidden, NULL);
1809 * gtk_file_chooser_get_show_hidden:
1810 * @chooser: a #GtkFileChooser
1812 * Gets whether hidden files and folders are displayed in the file selector.
1813 * See gtk_file_chooser_set_show_hidden().
1815 * Return value: %TRUE if hidden files and folders are displayed.
1820 gtk_file_chooser_get_show_hidden (GtkFileChooser *chooser)
1822 gboolean show_hidden;
1824 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1826 g_object_get (chooser, "show-hidden", &show_hidden, NULL);
1833 /* DLL ABI stability backward compatibility versions */
1835 #undef gtk_file_chooser_get_filename
1838 gtk_file_chooser_get_filename (GtkFileChooser *chooser)
1840 gchar *utf8_filename = gtk_file_chooser_get_filename_utf8 (chooser);
1841 gchar *retval = g_locale_from_utf8 (utf8_filename, -1, NULL, NULL, NULL);
1843 g_free (utf8_filename);
1848 #undef gtk_file_chooser_set_filename
1851 gtk_file_chooser_set_filename (GtkFileChooser *chooser,
1852 const gchar *filename)
1854 gchar *utf8_filename = g_locale_to_utf8 (filename, -1, NULL, NULL, NULL);
1855 gboolean retval = gtk_file_chooser_set_filename_utf8 (chooser, utf8_filename);
1857 g_free (utf8_filename);
1862 #undef gtk_file_chooser_select_filename
1865 gtk_file_chooser_select_filename (GtkFileChooser *chooser,
1866 const gchar *filename)
1868 gchar *utf8_filename = g_locale_to_utf8 (filename, -1, NULL, NULL, NULL);
1869 gboolean retval = gtk_file_chooser_select_filename_utf8 (chooser, utf8_filename);
1871 g_free (utf8_filename);
1876 #undef gtk_file_chooser_unselect_filename
1879 gtk_file_chooser_unselect_filename (GtkFileChooser *chooser,
1880 const char *filename)
1882 gchar *utf8_filename = g_locale_to_utf8 (filename, -1, NULL, NULL, NULL);
1884 gtk_file_chooser_unselect_filename_utf8 (chooser, utf8_filename);
1885 g_free (utf8_filename);
1888 #undef gtk_file_chooser_get_filenames
1891 gtk_file_chooser_get_filenames (GtkFileChooser *chooser)
1893 GSList *list = gtk_file_chooser_get_filenames_utf8 (chooser);
1894 GSList *rover = list;
1898 gchar *tem = (gchar *) rover->data;
1899 rover->data = g_locale_from_utf8 ((gchar *) rover->data, -1, NULL, NULL, NULL);
1901 rover = rover->next;
1907 #undef gtk_file_chooser_set_current_folder
1910 gtk_file_chooser_set_current_folder (GtkFileChooser *chooser,
1911 const gchar *filename)
1913 gchar *utf8_filename = g_locale_to_utf8 (filename, -1, NULL, NULL, NULL);
1914 gboolean retval = gtk_file_chooser_set_current_folder_utf8 (chooser, utf8_filename);
1916 g_free (utf8_filename);
1921 #undef gtk_file_chooser_get_current_folder
1924 gtk_file_chooser_get_current_folder (GtkFileChooser *chooser)
1926 gchar *utf8_folder = gtk_file_chooser_get_current_folder_utf8 (chooser);
1927 gchar *retval = g_locale_from_utf8 (utf8_folder, -1, NULL, NULL, NULL);
1929 g_free (utf8_folder);
1934 #undef gtk_file_chooser_get_preview_filename
1937 gtk_file_chooser_get_preview_filename (GtkFileChooser *chooser)
1939 char *utf8_filename = gtk_file_chooser_get_preview_filename_utf8 (chooser);
1940 char *retval = g_locale_from_utf8 (utf8_filename, -1, NULL, NULL, NULL);
1942 g_free (utf8_filename);
1947 #undef gtk_file_chooser_add_shortcut_folder
1950 gtk_file_chooser_add_shortcut_folder (GtkFileChooser *chooser,
1954 char *utf8_folder = g_locale_to_utf8 (folder, -1, NULL, NULL, NULL);
1956 gtk_file_chooser_add_shortcut_folder_utf8 (chooser, utf8_folder, error);
1958 g_free (utf8_folder);
1963 #undef gtk_file_chooser_remove_shortcut_folder
1966 gtk_file_chooser_remove_shortcut_folder (GtkFileChooser *chooser,
1970 char *utf8_folder = g_locale_to_utf8 (folder, -1, NULL, NULL, NULL);
1972 gtk_file_chooser_remove_shortcut_folder_utf8 (chooser, utf8_folder, error);
1974 g_free (utf8_folder);
1979 #undef gtk_file_chooser_list_shortcut_folders
1982 gtk_file_chooser_list_shortcut_folders (GtkFileChooser *chooser)
1984 GSList *list = gtk_file_chooser_list_shortcut_folders_utf8 (chooser);
1985 GSList *rover = list;
1989 gchar *tem = (gchar *) rover->data;
1990 rover->data = g_locale_from_utf8 ((gchar *) rover->data, -1, NULL, NULL, NULL);
1992 rover = rover->next;