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"
30 static void gtk_file_chooser_class_init (gpointer g_iface);
32 static GtkFilePath *gtk_file_chooser_get_path (GtkFileChooser *chooser);
35 gtk_file_chooser_get_type (void)
37 static GType file_chooser_type = 0;
39 if (!file_chooser_type)
41 static const GTypeInfo file_chooser_info =
43 sizeof (GtkFileChooserIface), /* class_size */
45 NULL, /* base_finalize */
46 (GClassInitFunc)gtk_file_chooser_class_init, /* class_init */
49 file_chooser_type = g_type_register_static (G_TYPE_INTERFACE,
51 &file_chooser_info, 0);
53 g_type_interface_add_prerequisite (file_chooser_type, GTK_TYPE_WIDGET);
56 return file_chooser_type;
60 gtk_file_chooser_class_init (gpointer g_iface)
62 GType iface_type = G_TYPE_FROM_INTERFACE (g_iface);
65 * GtkFileChooser::current-folder-changed
66 * @chooser: the object which received the signal.
68 * This signal is emitted when the current folder in a #GtkFileChooser
69 * changes. This can happen due to the user performing some action that
70 * changes folders, such as selecting a bookmark or visiting a folder on the
71 * file list. It can also happen as a result of calling a function to
72 * explicitly change the current folder in a file chooser.
74 * Normally you do not need to connect to this signal, unless you need to keep
75 * track of which folder a file chooser is showing.
77 * See also: gtk_file_chooser_set_current_folder(),
78 * gtk_file_chooser_get_current_folder(),
79 * gtk_file_chooser_set_current_folder_uri(),
80 * gtk_file_chooser_get_current_folder_uri().
82 g_signal_new ("current-folder-changed",
85 G_STRUCT_OFFSET (GtkFileChooserIface, current_folder_changed),
87 g_cclosure_marshal_VOID__VOID,
91 * GtkFileChooser::selection-changed
92 * @chooser: the object which received the signal.
94 * This signal is emitted when there is a change in the set of selected files
95 * in a #GtkFileChooser. This can happen when the user modifies the selection
96 * with the mouse or the keyboard, or when explicitly calling functions to
97 * change the selection.
99 * Normally you do not need to connect to this signal, as it is easier to wait
100 * for the file chooser to finish running, and then to get the list of
101 * selected files using the functions mentioned below.
103 * See also: gtk_file_chooser_select_filename(),
104 * gtk_file_chooser_unselect_filename(), gtk_file_chooser_get_filename(),
105 * gtk_file_chooser_get_filenames(), gtk_file_chooser_select_uri(),
106 * gtk_file_chooser_unselect_uri(), gtk_file_chooser_get_uri(),
107 * gtk_file_chooser_get_uris().
109 g_signal_new ("selection-changed",
112 G_STRUCT_OFFSET (GtkFileChooserIface, selection_changed),
114 g_cclosure_marshal_VOID__VOID,
118 * GtkFileChooser::update-preview
119 * @chooser: the object which received the signal.
121 * This signal is emitted when the preview in a file chooser should be
122 * regenerated. For example, this can happen when the currently selected file
123 * changes. You should use this signal if you want your file chooser to have
126 * Once you have installed a preview widget with
127 * gtk_file_chooser_set_preview_widget(), you should update it when this
128 * signal is emitted. You can use the functions
129 * gtk_file_chooser_get_preview_filename() or
130 * gtk_file_chooser_get_preview_uri() to get the name of the file to preview.
131 * Your widget may not be able to preview all kinds of files; your callback
132 * must call gtk_file_chooser_set_preview_wiget_active() to inform the file
133 * chooser about whether the preview was generated successfully or not.
135 * Please see the example code in <xref linkend="gtkfilechooser-preview"/>.
137 * See also: gtk_file_chooser_set_preview_widget(),
138 * gtk_file_chooser_set_preview_widget_active(),
139 * gtk_file_chooser_set_use_preview_label(),
140 * gtk_file_chooser_get_preview_filename(),
141 * gtk_file_chooser_get_preview_uri().
143 g_signal_new ("update-preview",
146 G_STRUCT_OFFSET (GtkFileChooserIface, update_preview),
148 g_cclosure_marshal_VOID__VOID,
152 * GtkFileChooser::file-activated
153 * @chooser: the object which received the signal.
155 * This signal is emitted when the user "activates" a file in the file
156 * chooser. This can happen by double-clicking on a file in the file list, or
157 * by pressing <keycap>Enter</keycap>.
159 * Normally you do not need to connect to this signal. It is used internally
160 * by #GtkFileChooserDialog to know when to activate the default button in the
163 * See also: gtk_file_chooser_get_filename(),
164 * gtk_file_chooser_get_filenames(), gtk_file_chooser_get_uri(),
165 * gtk_file_chooser_get_uris().
167 g_signal_new ("file-activated",
170 G_STRUCT_OFFSET (GtkFileChooserIface, file_activated),
172 g_cclosure_marshal_VOID__VOID,
175 g_object_interface_install_property (g_iface,
176 g_param_spec_enum ("action",
178 P_("The type of operation that the file selector is performing"),
179 GTK_TYPE_FILE_CHOOSER_ACTION,
180 GTK_FILE_CHOOSER_ACTION_OPEN,
181 GTK_PARAM_READWRITE));
182 g_object_interface_install_property (g_iface,
183 g_param_spec_string ("file-system-backend",
184 P_("File System Backend"),
185 P_("Name of file system backend to use"),
187 GTK_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
188 g_object_interface_install_property (g_iface,
189 g_param_spec_object ("filter",
191 P_("The current filter for selecting which files are displayed"),
192 GTK_TYPE_FILE_FILTER,
193 GTK_PARAM_READWRITE));
194 g_object_interface_install_property (g_iface,
195 g_param_spec_boolean ("local-only",
197 P_("Whether the selected file(s) should be limited to local file: URLs"),
199 GTK_PARAM_READWRITE));
200 g_object_interface_install_property (g_iface,
201 g_param_spec_object ("preview-widget",
202 P_("Preview widget"),
203 P_("Application supplied widget for custom previews."),
205 GTK_PARAM_READWRITE));
206 g_object_interface_install_property (g_iface,
207 g_param_spec_boolean ("preview-widget-active",
208 P_("Preview Widget Active"),
209 P_("Whether the application supplied widget for custom previews should be shown."),
211 GTK_PARAM_READWRITE));
212 g_object_interface_install_property (g_iface,
213 g_param_spec_boolean ("use-preview-label",
214 P_("Use Preview Label"),
215 P_("Whether to display a stock label with the name of the previewed file."),
217 GTK_PARAM_READWRITE));
218 g_object_interface_install_property (g_iface,
219 g_param_spec_object ("extra-widget",
221 P_("Application supplied widget for extra options."),
223 GTK_PARAM_READWRITE));
224 g_object_interface_install_property (g_iface,
225 g_param_spec_boolean ("select-multiple",
226 P_("Select Multiple"),
227 P_("Whether to allow multiple files to be selected"),
229 GTK_PARAM_READWRITE));
231 g_object_interface_install_property (g_iface,
232 g_param_spec_boolean ("show-hidden",
234 P_("Whether the hidden files and folders should be displayed"),
236 GTK_PARAM_READWRITE));
240 * gtk_file_chooser_error_quark:
242 * Registers an error quark for #GtkFileChooser if necessary.
244 * Return value: The error quark used for #GtkFileChooser errors.
249 gtk_file_chooser_error_quark (void)
251 static GQuark quark = 0;
253 quark = g_quark_from_static_string ("gtk-file-chooser-error-quark");
258 * gtk_file_chooser_set_action:
259 * @chooser: a #GtkFileChooser
260 * @action: the action that the file selector is performing
262 * Sets the type of operation that the chooser is performing; the
263 * user interface is adapted to suit the selected action. For example,
264 * an option to create a new folder might be shown if the action is
265 * %GTK_FILE_CHOOSER_ACTION_SAVE but not if the action is
266 * %GTK_FILE_CHOOSER_ACTION_OPEN.
271 gtk_file_chooser_set_action (GtkFileChooser *chooser,
272 GtkFileChooserAction action)
274 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
276 g_object_set (chooser, "action", action, NULL);
280 * gtk_file_chooser_get_action:
281 * @chooser: a #GtkFileChooser
283 * Gets the type of operation that the file chooser is performing; see
284 * gtk_file_chooser_set_action().
286 * Return value: the action that the file selector is performing
291 gtk_file_chooser_get_action (GtkFileChooser *chooser)
293 GtkFileChooserAction action;
295 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
297 g_object_get (chooser, "action", &action, NULL);
303 * gtk_file_chooser_set_local_only:
304 * @chooser: a #GtkFileChooser
305 * @local_only: %TRUE if only local files can be selected
307 * Sets whether only local files can be selected in the
308 * file selector. If @local_only is %TRUE (the default),
309 * then the selected file are files are guaranteed to be
310 * accessible through the operating systems native file
311 * file system and therefore the application only
312 * needs to worry about the filename functions in
313 * #GtkFileChooser, like gtk_file_chooser_get_filename(),
314 * rather than the URI functions like
315 * gtk_file_chooser_get_uri(),
320 gtk_file_chooser_set_local_only (GtkFileChooser *chooser,
323 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
325 g_object_set (chooser, "local-only", local_only, NULL);
329 * gtk_file_chooser_get_local_only:
330 * @chooser: a #GtkFileChoosre
332 * Gets whether only local files can be selected in the
333 * file selector. See gtk_file_chooser_set_local_only()
335 * Return value: %TRUE if only local files can be selected.
340 gtk_file_chooser_get_local_only (GtkFileChooser *chooser)
344 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
346 g_object_get (chooser, "local-only", &local_only, NULL);
352 * gtk_file_chooser_set_select_multiple:
353 * @chooser: a #GtkFileChooser
354 * @select_multiple: %TRUE if multiple files can be selected.
356 * Sets whether multiple files can be selected in the file selector. This is
357 * only relevant if the action is set to be GTK_FILE_CHOOSER_ACTION_OPEN or
358 * GTK_FILE_CHOOSER_ACTION_SAVE. It cannot be set with either of the folder
364 gtk_file_chooser_set_select_multiple (GtkFileChooser *chooser,
365 gboolean select_multiple)
367 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
369 g_object_set (chooser, "select-multiple", select_multiple, NULL);
373 * gtk_file_chooser_get_select_multiple:
374 * @chooser: a #GtkFileChooser
376 * Gets whether multiple files can be selected in the file
377 * selector. See gtk_file_chooser_set_select_multiple().
379 * Return value: %TRUE if multiple files can be selected.
384 gtk_file_chooser_get_select_multiple (GtkFileChooser *chooser)
386 gboolean select_multiple;
388 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
390 g_object_get (chooser, "select-multiple", &select_multiple, NULL);
392 return select_multiple;
396 * gtk_file_chooser_get_filename:
397 * @chooser: a #GtkFileChooser
399 * Gets the filename for the currently selected file in
400 * the file selector. If multiple files are selected,
401 * one of the filenames will be returned at random.
403 * If the file chooser is in folder mode, this function returns the selected
406 * Return value: The currently selected filename, or %NULL
407 * if no file is selected, or the selected file can't
408 * be represented with a local filename. Free with g_free().
413 gtk_file_chooser_get_filename (GtkFileChooser *chooser)
415 GtkFileSystem *file_system;
417 gchar *result = NULL;
419 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
421 file_system = _gtk_file_chooser_get_file_system (chooser);
422 path = gtk_file_chooser_get_path (chooser);
425 result = gtk_file_system_path_to_filename (file_system, path);
426 gtk_file_path_free (path);
433 * gtk_file_chooser_set_filename:
434 * @chooser: a #GtkFileChooser
435 * @filename: the filename to set as current
437 * Sets @filename as the current filename for the file chooser;
438 * If the file name isn't in the current folder of @chooser, then the
439 * current folder of @chooser will be changed to the folder containing
440 * @filename. This is equivalent to a sequence of
441 * gtk_file_chooser_unselect_all() followed by gtk_file_chooser_select_filename().
443 * Note that the file must exist, or nothing will be done except
444 * for the directory change. To pre-enter a filename for the user, as in
445 * a save-as dialog, use gtk_file_chooser_set_current_name()
447 * Return value: %TRUE if both the folder could be changed and the file was
448 * selected successfully, %FALSE otherwise.
453 gtk_file_chooser_set_filename (GtkFileChooser *chooser,
454 const gchar *filename)
456 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
458 gtk_file_chooser_unselect_all (chooser);
459 return gtk_file_chooser_select_filename (chooser, filename);
463 * gtk_file_chooser_select_filename:
464 * @chooser: a #GtkFileChooser
465 * @filename: the filename to select
467 * Selects a filename. If the file name isn't in the current
468 * folder of @chooser, then the current folder of @chooser will
469 * be changed to the folder containing @filename.
471 * Return value: %TRUE if both the folder could be changed and the file was
472 * selected successfully, %FALSE otherwise.
477 gtk_file_chooser_select_filename (GtkFileChooser *chooser,
478 const gchar *filename)
480 GtkFileSystem *file_system;
484 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
485 g_return_val_if_fail (filename != NULL, FALSE);
487 file_system = _gtk_file_chooser_get_file_system (chooser);
489 path = gtk_file_system_filename_to_path (file_system, filename);
492 result = _gtk_file_chooser_select_path (chooser, path, NULL);
493 gtk_file_path_free (path);
502 * gtk_file_chooser_unselect_filename:
503 * @chooser: a #GtkFileChooser
504 * @filename: the filename to unselect
506 * Unselects a currently selected filename. If the filename
507 * is not in the current directory, does not exist, or
508 * is otherwise not currently selected, does nothing.
513 gtk_file_chooser_unselect_filename (GtkFileChooser *chooser,
514 const char *filename)
516 GtkFileSystem *file_system;
519 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
520 g_return_if_fail (filename != NULL);
522 file_system = _gtk_file_chooser_get_file_system (chooser);
524 path = gtk_file_system_filename_to_path (file_system, filename);
527 _gtk_file_chooser_unselect_path (chooser, path);
528 gtk_file_path_free (path);
532 /* Converts a list of GtkFilePath* to a list of strings using the specified function */
534 file_paths_to_strings (GtkFileSystem *fs,
536 gchar * (*convert_func) (GtkFileSystem *fs, const GtkFilePath *path))
542 for (; paths; paths = paths->next)
548 string = (* convert_func) (fs, path);
551 strings = g_slist_prepend (strings, string);
554 return g_slist_reverse (strings);
558 * gtk_file_chooser_get_filenames:
559 * @chooser: a #GtkFileChooser
561 * Lists all the selected files and subfolders in the current folder of
562 * @chooser. The returned names are full absolute paths. If files in the current
563 * folder cannot be represented as local filenames they will be ignored. (See
564 * gtk_file_chooser_get_uris())
566 * Return value: a #GSList containing the filenames of all selected
567 * files and subfolders in the current folder. Free the returned list
568 * with g_slist_free(), and the filenames with g_free().
573 gtk_file_chooser_get_filenames (GtkFileChooser *chooser)
575 GtkFileSystem *file_system;
579 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
581 file_system = _gtk_file_chooser_get_file_system (chooser);
582 paths = _gtk_file_chooser_get_paths (chooser);
584 result = file_paths_to_strings (file_system, paths, gtk_file_system_path_to_filename);
585 gtk_file_paths_free (paths);
590 * gtk_file_chooser_set_current_folder:
591 * @chooser: a #GtkFileChooser
592 * @filename: the full path of the new current folder
594 * Sets the current folder for @chooser from a local filename.
595 * The user will be shown the full contents of the current folder,
596 * plus user interface elements for navigating to other folders.
598 * Return value: %TRUE if the folder could be changed successfully, %FALSE
604 gtk_file_chooser_set_current_folder (GtkFileChooser *chooser,
605 const gchar *filename)
607 GtkFileSystem *file_system;
611 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
612 g_return_val_if_fail (filename != NULL, FALSE);
614 file_system = _gtk_file_chooser_get_file_system (chooser);
616 path = gtk_file_system_filename_to_path (file_system, filename);
619 result = _gtk_file_chooser_set_current_folder_path (chooser, path, NULL);
620 gtk_file_path_free (path);
629 * gtk_file_chooser_get_current_folder:
630 * @chooser: a #GtkFileChooser
632 * Gets the current folder of @chooser as a local filename.
633 * See gtk_file_chooser_set_current_folder().
635 * Return value: the full path of the current folder, or %NULL
636 * if the current path cannot be represented as a local filename.
637 * Free with g_free().
642 gtk_file_chooser_get_current_folder (GtkFileChooser *chooser)
644 GtkFileSystem *file_system;
648 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
650 file_system = _gtk_file_chooser_get_file_system (chooser);
652 path = _gtk_file_chooser_get_current_folder_path (chooser);
653 filename = gtk_file_system_path_to_filename (file_system, path);
654 gtk_file_path_free (path);
660 * gtk_file_chooser_set_current_name:
661 * @chooser: a #GtkFileChooser
662 * @name: the filename to use, as a UTF-8 string
664 * Sets the current name in the file selector, as if entered
665 * by the user. Note that the name passed in here is a UTF-8
666 * string rather than a filename. This function is meant for
667 * such uses as a suggested name in a "Save As..." dialog.
669 * If you want to preselect a particular existing file, you
670 * should use gtk_file_chooser_set_filename() instead.
675 gtk_file_chooser_set_current_name (GtkFileChooser *chooser,
678 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
679 g_return_if_fail (name != NULL);
681 GTK_FILE_CHOOSER_GET_IFACE (chooser)->set_current_name (chooser, name);
685 * gtk_file_chooser_get_uri:
686 * @chooser: a #GtkFileChooser
688 * Gets the URI for the currently selected file in
689 * the file selector. If multiple files are selected,
690 * one of the filenames will be returned at random.
692 * If the file chooser is in folder mode, this function returns the selected
695 * Return value: The currently selected URI, or %NULL
696 * if no file is selected. Free with g_free()
701 gtk_file_chooser_get_uri (GtkFileChooser *chooser)
703 GtkFileSystem *file_system;
705 gchar *result = NULL;
707 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
709 file_system = _gtk_file_chooser_get_file_system (chooser);
710 path = gtk_file_chooser_get_path (chooser);
713 result = gtk_file_system_path_to_uri (file_system, path);
714 gtk_file_path_free (path);
721 * gtk_file_chooser_set_uri:
722 * @chooser: a #GtkFileChooser
723 * @uri: the URI to set as current
725 * Sets the file referred to by @uri as the current file for the
726 * file chooser; If the file name isn't in the current folder of @chooser,
727 * then the current folder of @chooser will be changed to the folder containing
728 * @uri. This is equivalent to a sequence of gtk_file_chooser_unselect_all()
729 * followed by gtk_file_chooser_select_uri().
731 * Note that the file must exist, or nothing will be done except
732 * for the directory change. To pre-enter a filename for the user, as in
733 * a save-as dialog, use gtk_file_chooser_set_current_name()
735 * Return value: %TRUE if both the folder could be changed and the URI was
736 * selected successfully, %FALSE otherwise.
741 gtk_file_chooser_set_uri (GtkFileChooser *chooser,
744 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
746 gtk_file_chooser_unselect_all (chooser);
747 return gtk_file_chooser_select_uri (chooser, uri);
751 * gtk_file_chooser_select_uri:
752 * @chooser: a #GtkFileChooser
753 * @uri: the URI to select
755 * Selects the file to by @uri. If the URI doesn't refer to a
756 * file in the current folder of @chooser, then the current folder of
757 * @chooser will be changed to the folder containing @filename.
759 * Return value: %TRUE if both the folder could be changed and the URI was
760 * selected successfully, %FALSE otherwise.
765 gtk_file_chooser_select_uri (GtkFileChooser *chooser,
768 GtkFileSystem *file_system;
772 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
773 g_return_val_if_fail (uri != NULL, FALSE);
775 file_system = _gtk_file_chooser_get_file_system (chooser);
777 path = gtk_file_system_uri_to_path (file_system, uri);
780 result = _gtk_file_chooser_select_path (chooser, path, NULL);
781 gtk_file_path_free (path);
790 * gtk_file_chooser_unselect_uri:
791 * @chooser: a #GtkFileChooser
792 * @uri: the URI to unselect
794 * Unselects the file referred to by @uri. If the file
795 * is not in the current directory, does not exist, or
796 * is otherwise not currently selected, does nothing.
801 gtk_file_chooser_unselect_uri (GtkFileChooser *chooser,
804 GtkFileSystem *file_system;
807 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
808 g_return_if_fail (uri != NULL);
810 file_system = _gtk_file_chooser_get_file_system (chooser);
812 path = gtk_file_system_uri_to_path (file_system, uri);
815 _gtk_file_chooser_unselect_path (chooser, path);
816 gtk_file_path_free (path);
821 * gtk_file_chooser_select_all:
822 * @chooser: a #GtkFileChooser
824 * Selects all the files in the current folder of a file chooser.
829 gtk_file_chooser_select_all (GtkFileChooser *chooser)
831 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
833 GTK_FILE_CHOOSER_GET_IFACE (chooser)->select_all (chooser);
837 * gtk_file_chooser_unselect_all:
838 * @chooser: a #GtkFileChooser
840 * Unselects all the files in the current folder of a file chooser.
845 gtk_file_chooser_unselect_all (GtkFileChooser *chooser)
848 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
850 GTK_FILE_CHOOSER_GET_IFACE (chooser)->unselect_all (chooser);
854 * gtk_file_chooser_get_uris:
855 * @chooser: a #GtkFileChooser
857 * Lists all the selected files and subfolders in the current folder of
858 * @chooser. The returned names are full absolute URIs.
860 * Return value: a #GSList containing the URIs of all selected
861 * files and subfolders in the current folder. Free the returned list
862 * with g_slist_free(), and the filenames with g_free().
867 gtk_file_chooser_get_uris (GtkFileChooser *chooser)
869 GtkFileSystem *file_system;
873 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
875 file_system = _gtk_file_chooser_get_file_system (chooser);
876 paths = _gtk_file_chooser_get_paths (chooser);
878 result = file_paths_to_strings (file_system, paths, gtk_file_system_path_to_uri);
879 gtk_file_paths_free (paths);
884 * gtk_file_chooser_set_current_folder_uri:
885 * @chooser: a #GtkFileChooser
886 * @uri: the URI for the new current folder
888 * Sets the current folder for @chooser from an URI.
889 * The user will be shown the full contents of the current folder,
890 * plus user interface elements for navigating to other folders.
892 * Return value: %TRUE if the folder could be changed successfully, %FALSE
898 gtk_file_chooser_set_current_folder_uri (GtkFileChooser *chooser,
901 GtkFileSystem *file_system;
905 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
906 g_return_val_if_fail (uri != NULL, FALSE);
908 file_system = _gtk_file_chooser_get_file_system (chooser);
910 path = gtk_file_system_uri_to_path (file_system, uri);
913 result = _gtk_file_chooser_set_current_folder_path (chooser, path, NULL);
914 gtk_file_path_free (path);
923 * gtk_file_chooser_get_current_folder_uri:
924 * @chooser: a #GtkFileChooser
926 * Gets the current folder of @chooser as an URI.
927 * See gtk_file_chooser_set_current_folder_uri().
929 * Return value: the URI for the current folder.
930 * Free with g_free().
935 gtk_file_chooser_get_current_folder_uri (GtkFileChooser *chooser)
937 GtkFileSystem *file_system;
941 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
943 file_system = _gtk_file_chooser_get_file_system (chooser);
945 path = _gtk_file_chooser_get_current_folder_path (chooser);
946 uri = gtk_file_system_path_to_uri (file_system, path);
947 gtk_file_path_free (path);
953 * _gtk_file_chooser_set_current_folder_path:
954 * @chooser: a #GtkFileChooser
955 * @path: the #GtkFilePath for the new folder
956 * @error: location to store error, or %NULL.
958 * Sets the current folder for @chooser from a #GtkFilePath.
959 * Internal function, see gtk_file_chooser_set_current_folder_uri().
961 * Return value: %TRUE if the folder could be changed successfully, %FALSE
967 _gtk_file_chooser_set_current_folder_path (GtkFileChooser *chooser,
968 const GtkFilePath *path,
971 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
972 g_return_val_if_fail (path != NULL, FALSE);
973 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
975 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->set_current_folder (chooser, path, error);
979 * _gtk_file_chooser_get_current_folder_path:
980 * @chooser: a #GtkFileChooser
982 * Gets the current folder of @chooser as #GtkFilePath.
983 * See gtk_file_chooser_get_current_folder_uri().
985 * Return value: the #GtkFilePath for the current folder.
986 * Free with gtk_file_path_free().
991 _gtk_file_chooser_get_current_folder_path (GtkFileChooser *chooser)
993 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
995 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_current_folder (chooser);
999 * _gtk_file_chooser_select_path:
1000 * @chooser: a #GtkFileChooser
1001 * @path: the path to select
1002 * @error: location to store error, or %NULL
1004 * Selects the file referred to by @path. An internal function. See
1005 * _gtk_file_chooser_select_uri().
1007 * Return value: %TRUE if both the folder could be changed and the path was
1008 * selected successfully, %FALSE otherwise.
1013 _gtk_file_chooser_select_path (GtkFileChooser *chooser,
1014 const GtkFilePath *path,
1017 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1018 g_return_val_if_fail (path != NULL, FALSE);
1019 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
1021 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->select_path (chooser, path, error);
1025 * _gtk_file_chooser_unselect_path:
1026 * @chooser: a #GtkFileChooser
1027 * @path: the filename to path
1029 * Unselects the file referred to by @path. An internal
1030 * function. See _gtk_file_chooser_unselect_uri().
1035 _gtk_file_chooser_unselect_path (GtkFileChooser *chooser,
1036 const GtkFilePath *path)
1038 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1040 GTK_FILE_CHOOSER_GET_IFACE (chooser)->unselect_path (chooser, path);
1044 * _gtk_file_chooser_get_paths:
1045 * @chooser: a #GtkFileChooser
1047 * Lists all the selected files and subfolders in the current folder of @chooser
1048 * as #GtkFilePath. An internal function, see gtk_file_chooser_get_uris().
1050 * Return value: a #GSList containing a #GtkFilePath for each selected
1051 * file and subfolder in the current folder. Free the returned list
1052 * with g_slist_free(), and the paths with gtk_file_path_free().
1057 _gtk_file_chooser_get_paths (GtkFileChooser *chooser)
1059 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1061 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_paths (chooser);
1064 static GtkFilePath *
1065 gtk_file_chooser_get_path (GtkFileChooser *chooser)
1068 GtkFilePath *result = NULL;
1070 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1072 list = _gtk_file_chooser_get_paths (chooser);
1075 result = list->data;
1076 list = g_slist_delete_link (list, list);
1077 gtk_file_paths_free (list);
1084 * _gtk_file_chooser_get_file_system:
1085 * @chooser: a #GtkFileChooser
1087 * Gets the #GtkFileSystem of @chooser; this is an internal
1088 * implementation detail, used for conversion between paths
1089 * and filenames and URIs.
1091 * Return value: the file system for @chooser.
1096 _gtk_file_chooser_get_file_system (GtkFileChooser *chooser)
1098 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1100 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_file_system (chooser);
1106 * gtk_file_chooser_set_preview_widget:
1107 * @chooser: a #GtkFileChooser
1108 * @preview_widget: widget for displaying preview.
1110 * Sets an application-supplied widget to use to display a custom preview
1111 * of the currently selected file. To implement a preview, after setting the
1112 * preview widget, you connect to the ::update-preview
1113 * signal, and call gtk_file_chooser_get_preview_filename() or
1114 * gtk_file_chooser_get_preview_uri() on each change. If you can
1115 * display a preview of the new file, update your widget and
1116 * set the preview active using gtk_file_chooser_set_preview_widget_active().
1117 * Otherwise, set the preview inactive.
1119 * When there is no application-supplied preview widget, or the
1120 * application-supplied preview widget is not active, the file chooser
1121 * may display an internally generated preview of the current file or
1122 * it may display no preview at all.
1127 gtk_file_chooser_set_preview_widget (GtkFileChooser *chooser,
1128 GtkWidget *preview_widget)
1130 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1132 g_object_set (chooser, "preview-widget", preview_widget, NULL);
1136 * gtk_file_chooser_get_preview_widget:
1137 * @chooser: a #GtkFileChooser
1139 * Gets the current preview widget; see
1140 * gtk_file_chooser_set_preview_widget().
1142 * Return value: the current preview widget, or %NULL
1147 gtk_file_chooser_get_preview_widget (GtkFileChooser *chooser)
1149 GtkWidget *preview_widget;
1151 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1153 g_object_get (chooser, "preview-widget", &preview_widget, NULL);
1155 /* Horrid hack; g_object_get() refs returned objects but
1156 * that contradicts the memory management conventions
1160 g_object_unref (preview_widget);
1162 return preview_widget;
1166 * gtk_file_chooser_set_preview_widget_active:
1167 * @chooser: a #GtkFileChooser
1168 * @active: whether to display the user-specified preview widget
1170 * Sets whether the preview widget set by
1171 * gtk_file_chooser_set_preview_widget() should be shown for the
1172 * current filename. When @active is set to false, the file chooser
1173 * may display an internally generated preview of the current file
1174 * or it may display no preview at all. See
1175 * gtk_file_chooser_set_preview_widget() for more details.
1180 gtk_file_chooser_set_preview_widget_active (GtkFileChooser *chooser,
1183 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1185 g_object_set (chooser, "preview-widget-active", active, NULL);
1189 * gtk_file_chooser_get_preview_widget_active:
1190 * @chooser: a #GtkFileChooser
1192 * Gets whether the preview widget set by gtk_file_chooser_set_preview_widget()
1193 * should be shown for the current filename. See
1194 * gtk_file_chooser_set_preview_widget_active().
1196 * Return value: %TRUE if the preview widget is active for the current filename.
1201 gtk_file_chooser_get_preview_widget_active (GtkFileChooser *chooser)
1205 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1207 g_object_get (chooser, "preview-widget-active", &active, NULL);
1213 * gtk_file_chooser_set_use_preview_label:
1214 * @chooser: a #GtkFileChooser
1215 * @use_label: whether to display a stock label with the name of the previewed file
1217 * Sets whether the file chooser should display a stock label with the name of
1218 * the file that is being previewed; the default is %TRUE. Applications that
1219 * want to draw the whole preview area themselves should set this to %FALSE and
1220 * display the name themselves in their preview widget.
1222 * See also: gtk_file_chooser_set_preview_widget()
1227 gtk_file_chooser_set_use_preview_label (GtkFileChooser *chooser,
1230 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1232 g_object_set (chooser, "use-preview-label", use_label, NULL);
1236 * gtk_file_chooser_get_use_preview_label:
1237 * @chooser: a #GtkFileChooser
1239 * Gets whether a stock label should be drawn with the name of the previewed
1240 * file. See gtk_file_chooser_set_use_preview_label().
1242 * Return value: %TRUE if the file chooser is set to display a label with the
1243 * name of the previewed file, %FALSE otherwise.
1246 gtk_file_chooser_get_use_preview_label (GtkFileChooser *chooser)
1250 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1252 g_object_get (chooser, "use-preview-label", &use_label, NULL);
1258 * gtk_file_chooser_get_preview_filename:
1259 * @chooser: a #GtkFileChooser
1261 * Gets the filename that should be previewed in a custom preview
1262 * Internal function, see gtk_file_chooser_get_preview_uri().
1264 * Return value: the #GtkFilePath for the file to preview, or %NULL if no file
1265 * is selected. Free with gtk_file_path_free().
1270 _gtk_file_chooser_get_preview_path (GtkFileChooser *chooser)
1272 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1274 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_preview_path (chooser);
1278 * _gtk_file_chooser_add_shortcut_folder:
1279 * @chooser: a #GtkFileChooser
1280 * @path: path of the folder to add
1281 * @error: location to store error, or %NULL
1283 * Adds a folder to be displayed with the shortcut folders in a file chooser.
1284 * Internal function, see gtk_file_chooser_add_shortcut_folder().
1286 * Return value: %TRUE if the folder could be added successfully, %FALSE
1292 _gtk_file_chooser_add_shortcut_folder (GtkFileChooser *chooser,
1293 const GtkFilePath *path,
1296 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1297 g_return_val_if_fail (path != NULL, FALSE);
1299 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_shortcut_folder (chooser, path, error);
1303 * _gtk_file_chooser_remove_shortcut_folder:
1304 * @chooser: a #GtkFileChooser
1305 * @path: path of the folder to remove
1306 * @error: location to store error, or %NULL
1308 * Removes a folder from the shortcut folders in a file chooser. Internal
1309 * function, see gtk_file_chooser_remove_shortcut_folder().
1311 * Return value: %TRUE if the folder could be removed successfully, %FALSE
1317 _gtk_file_chooser_remove_shortcut_folder (GtkFileChooser *chooser,
1318 const GtkFilePath *path,
1321 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1322 g_return_val_if_fail (path != NULL, FALSE);
1324 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_shortcut_folder (chooser, path, error);
1328 * gtk_file_chooser_get_preview_filename:
1329 * @chooser: a #GtkFileChooser
1331 * Gets the filename that should be previewed in a custom preview
1332 * widget. See gtk_file_chooser_set_preview_widget().
1334 * Return value: the filename to preview, or %NULL if no file
1335 * is selected, or if the selected file cannot be represented
1336 * as a local filename. Free with g_free()
1341 gtk_file_chooser_get_preview_filename (GtkFileChooser *chooser)
1343 GtkFileSystem *file_system;
1345 gchar *result = NULL;
1347 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1349 file_system = _gtk_file_chooser_get_file_system (chooser);
1350 path = _gtk_file_chooser_get_preview_path (chooser);
1353 result = gtk_file_system_path_to_filename (file_system, path);
1354 gtk_file_path_free (path);
1361 * gtk_file_chooser_get_preview_uri:
1362 * @chooser: a #GtkFileChooser
1364 * Gets the URI that should be previewed in a custom preview
1365 * widget. See gtk_file_chooser_set_preview_widget().
1367 * Return value: the URI for the file to preview, or %NULL if no file is
1368 * selected. Free with g_free().
1373 gtk_file_chooser_get_preview_uri (GtkFileChooser *chooser)
1375 GtkFileSystem *file_system;
1377 gchar *result = NULL;
1379 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1381 file_system = _gtk_file_chooser_get_file_system (chooser);
1382 path = _gtk_file_chooser_get_preview_path (chooser);
1385 result = gtk_file_system_path_to_uri (file_system, path);
1386 gtk_file_path_free (path);
1393 * gtk_file_chooser_set_extra_widget:
1394 * @chooser: a #GtkFileChooser
1395 * @extra_widget: widget for extra options
1397 * Sets an application-supplied widget to provide extra options to the user.
1402 gtk_file_chooser_set_extra_widget (GtkFileChooser *chooser,
1403 GtkWidget *extra_widget)
1405 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1407 g_object_set (chooser, "extra-widget", extra_widget, NULL);
1411 * gtk_file_chooser_get_extra_widget:
1412 * @chooser: a #GtkFileChooser
1414 * Gets the current preview widget; see
1415 * gtk_file_chooser_set_extra_widget().
1417 * Return value: the current extra widget, or %NULL
1422 gtk_file_chooser_get_extra_widget (GtkFileChooser *chooser)
1424 GtkWidget *extra_widget;
1426 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1428 g_object_get (chooser, "extra-widget", &extra_widget, NULL);
1430 /* Horrid hack; g_object_get() refs returned objects but
1431 * that contradicts the memory management conventions
1435 g_object_unref (extra_widget);
1437 return extra_widget;
1441 * gtk_file_chooser_add_filter:
1442 * @chooser: a #GtkFileChooser
1443 * @filter: a #GtkFileFilter
1445 * Adds @filter to the list of filters that the user can select between.
1446 * When a filter is selected, only files that are passed by that
1447 * filter are displayed.
1449 * Note that the @chooser takes ownership of the filter, so you have to
1450 * ref and sink it if you want to keep a reference.
1455 gtk_file_chooser_add_filter (GtkFileChooser *chooser,
1456 GtkFileFilter *filter)
1458 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1460 GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_filter (chooser, filter);
1464 * gtk_file_chooser_remove_filter:
1465 * @chooser: a #GtkFileChooser
1466 * @filter: a #GtkFileFilter
1468 * Removes @filter from the list of filters that the user can select between.
1473 gtk_file_chooser_remove_filter (GtkFileChooser *chooser,
1474 GtkFileFilter *filter)
1476 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1478 GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_filter (chooser, filter);
1482 * gtk_file_chooser_list_filters:
1483 * @chooser: a #GtkFileChooser
1485 * Lists the current set of user-selectable filters; see
1486 * gtk_file_chooser_add_filter(), gtk_file_chooser_remove_filter().
1488 * Return value: a #GSList containing the current set of
1489 * user selectable filters. The contents of the list are
1490 * owned by GTK+, but you must free the list itself with
1491 * g_slist_free() when you are done with it.
1496 gtk_file_chooser_list_filters (GtkFileChooser *chooser)
1498 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1500 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->list_filters (chooser);
1504 * gtk_file_chooser_set_filter:
1505 * @chooser: a #GtkFileChooser
1506 * @filter: a #GtkFileFilter
1508 * Sets the current filter; only the files that pass the
1509 * filter will be displayed. If the user-selectable list of filters
1510 * is non-empty, then the filter should be one of the filters
1511 * in that list. Setting the current filter when the list of
1512 * filters is empty is useful if you want to restrict the displayed
1513 * set of files without letting the user change it.
1518 gtk_file_chooser_set_filter (GtkFileChooser *chooser,
1519 GtkFileFilter *filter)
1521 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1522 g_return_if_fail (GTK_IS_FILE_FILTER (filter));
1524 g_object_set (chooser, "filter", filter, NULL);
1528 * gtk_file_chooser_get_filter:
1529 * @chooser: a #GtkFileChooser
1531 * Gets the current filter; see gtk_file_chooser_set_filter().
1533 * Return value: the current filter, or %NULL
1538 gtk_file_chooser_get_filter (GtkFileChooser *chooser)
1540 GtkFileFilter *filter;
1542 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1544 g_object_get (chooser, "filter", &filter, NULL);
1545 /* Horrid hack; g_object_get() refs returned objects but
1546 * that contradicts the memory management conventions
1550 g_object_unref (filter);
1556 * gtk_file_chooser_add_shortcut_folder:
1557 * @chooser: a #GtkFileChooser
1558 * @folder: filename of the folder to add
1559 * @error: location to store error, or %NULL
1561 * Adds a folder to be displayed with the shortcut folders in a file chooser.
1562 * Note that shortcut folders do not get saved, as they are provided by the
1563 * application. For example, you can use this to add a
1564 * "/usr/share/mydrawprogram/Clipart" folder to the volume list.
1566 * Return value: %TRUE if the folder could be added successfully, %FALSE
1567 * otherwise. In the latter case, the @error will be set as appropriate.
1572 gtk_file_chooser_add_shortcut_folder (GtkFileChooser *chooser,
1579 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1580 g_return_val_if_fail (folder != NULL, FALSE);
1582 path = gtk_file_system_filename_to_path (_gtk_file_chooser_get_file_system (chooser), folder);
1586 GTK_FILE_CHOOSER_ERROR,
1587 GTK_FILE_CHOOSER_ERROR_BAD_FILENAME,
1588 _("Invalid filename: %s"),
1593 result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_shortcut_folder (chooser, path, error);
1595 gtk_file_path_free (path);
1601 * gtk_file_chooser_remove_shortcut_folder:
1602 * @chooser: a #GtkFileChooser
1603 * @folder: filename of the folder to remove
1604 * @error: location to store error, or %NULL
1606 * Removes a folder from a file chooser's list of shortcut folders.
1608 * Return value: %TRUE if the operation succeeds, %FALSE otherwise.
1609 * In the latter case, the @error will be set as appropriate.
1611 * See also: gtk_file_chooser_add_shortcut_folder()
1616 gtk_file_chooser_remove_shortcut_folder (GtkFileChooser *chooser,
1623 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1624 g_return_val_if_fail (folder != NULL, FALSE);
1626 path = gtk_file_system_filename_to_path (_gtk_file_chooser_get_file_system (chooser), folder);
1630 GTK_FILE_CHOOSER_ERROR,
1631 GTK_FILE_CHOOSER_ERROR_BAD_FILENAME,
1632 _("Invalid filename: %s"),
1637 result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_shortcut_folder (chooser, path, error);
1639 gtk_file_path_free (path);
1645 * gtk_file_chooser_list_shortcut_folders:
1646 * @chooser: a #GtkFileChooser
1648 * Queries the list of shortcut folders in the file chooser, as set by
1649 * gtk_file_chooser_add_shortcut_folder().
1651 * Return value: A list of folder filenames, or %NULL if there are no shortcut
1652 * folders. Free the returned list with g_slist_free(), and the filenames with
1658 gtk_file_chooser_list_shortcut_folders (GtkFileChooser *chooser)
1663 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1665 folders = GTK_FILE_CHOOSER_GET_IFACE (chooser)->list_shortcut_folders (chooser);
1667 result = file_paths_to_strings (_gtk_file_chooser_get_file_system (chooser),
1669 gtk_file_system_path_to_filename);
1670 gtk_file_paths_free (folders);
1675 * gtk_file_chooser_add_shortcut_folder_uri:
1676 * @chooser: a #GtkFileChooser
1677 * @uri: URI of the folder to add
1678 * @error: location to store error, or %NULL
1680 * Adds a folder URI to be displayed with the shortcut folders in a file
1681 * chooser. Note that shortcut folders do not get saved, as they are provided
1682 * by the application. For example, you can use this to add a
1683 * "file:///usr/share/mydrawprogram/Clipart" folder to the volume list.
1685 * Return value: %TRUE if the folder could be added successfully, %FALSE
1686 * otherwise. In the latter case, the @error will be set as appropriate.
1691 gtk_file_chooser_add_shortcut_folder_uri (GtkFileChooser *chooser,
1698 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1699 g_return_val_if_fail (uri != NULL, FALSE);
1701 path = gtk_file_system_uri_to_path (_gtk_file_chooser_get_file_system (chooser), uri);
1705 GTK_FILE_CHOOSER_ERROR,
1706 GTK_FILE_CHOOSER_ERROR_BAD_FILENAME,
1707 _("Invalid filename: %s"),
1712 result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_shortcut_folder (chooser, path, error);
1714 gtk_file_path_free (path);
1720 * gtk_file_chooser_remove_shortcut_folder_uri:
1721 * @chooser: a #GtkFileChooser
1722 * @uri: URI of the folder to remove
1723 * @error: location to store error, or %NULL
1725 * Removes a folder URI from a file chooser's list of shortcut folders.
1727 * Return value: %TRUE if the operation succeeds, %FALSE otherwise.
1728 * In the latter case, the @error will be set as appropriate.
1730 * See also: gtk_file_chooser_add_shortcut_folder_uri()
1735 gtk_file_chooser_remove_shortcut_folder_uri (GtkFileChooser *chooser,
1742 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1743 g_return_val_if_fail (uri != NULL, FALSE);
1745 path = gtk_file_system_filename_to_path (_gtk_file_chooser_get_file_system (chooser), uri);
1749 GTK_FILE_CHOOSER_ERROR,
1750 GTK_FILE_CHOOSER_ERROR_BAD_FILENAME,
1751 _("Invalid filename: %s"),
1756 result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_shortcut_folder (chooser, path, error);
1758 gtk_file_path_free (path);
1764 * gtk_file_chooser_list_shortcut_folder_uris:
1765 * @chooser: a #GtkFileChooser
1767 * Queries the list of shortcut folders in the file chooser, as set by
1768 * gtk_file_chooser_add_shortcut_folder_uri().
1770 * Return value: A list of folder URIs, or %NULL if there are no shortcut
1771 * folders. Free the returned list with g_slist_free(), and the URIs with
1777 gtk_file_chooser_list_shortcut_folder_uris (GtkFileChooser *chooser)
1782 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1784 folders = GTK_FILE_CHOOSER_GET_IFACE (chooser)->list_shortcut_folders (chooser);
1786 result = file_paths_to_strings (_gtk_file_chooser_get_file_system (chooser),
1788 gtk_file_system_path_to_uri);
1789 gtk_file_paths_free (folders);
1795 * gtk_file_chooser_set_show_hidden:
1796 * @chooser: a #GtkFileChooser
1797 * @show_hidden: %TRUE if hidden files and folders should be displayed.
1799 * Sets whether hidden files and folders are displayed in the file selector.
1804 gtk_file_chooser_set_show_hidden (GtkFileChooser *chooser,
1805 gboolean show_hidden)
1807 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1809 g_object_set (chooser, "show-hidden", show_hidden, NULL);
1813 * gtk_file_chooser_get_show_hidden:
1814 * @chooser: a #GtkFileChooser
1816 * Gets whether hidden files and folders are displayed in the file selector.
1817 * See gtk_file_chooser_set_show_hidden().
1819 * Return value: %TRUE if hidden files and folders are displayed.
1824 gtk_file_chooser_get_show_hidden (GtkFileChooser *chooser)
1826 gboolean show_hidden;
1828 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1830 g_object_get (chooser, "show-hidden", &show_hidden, NULL);
1837 /* DLL ABI stability backward compatibility versions */
1839 #undef gtk_file_chooser_get_filename
1842 gtk_file_chooser_get_filename (GtkFileChooser *chooser)
1844 gchar *utf8_filename = gtk_file_chooser_get_filename_utf8 (chooser);
1845 gchar *retval = g_locale_from_utf8 (utf8_filename, -1, NULL, NULL, NULL);
1847 g_free (utf8_filename);
1852 #undef gtk_file_chooser_set_filename
1855 gtk_file_chooser_set_filename (GtkFileChooser *chooser,
1856 const gchar *filename)
1858 gchar *utf8_filename = g_locale_to_utf8 (filename, -1, NULL, NULL, NULL);
1859 gboolean retval = gtk_file_chooser_set_filename_utf8 (chooser, utf8_filename);
1861 g_free (utf8_filename);
1866 #undef gtk_file_chooser_select_filename
1869 gtk_file_chooser_select_filename (GtkFileChooser *chooser,
1870 const gchar *filename)
1872 gchar *utf8_filename = g_locale_to_utf8 (filename, -1, NULL, NULL, NULL);
1873 gboolean retval = gtk_file_chooser_select_filename_utf8 (chooser, utf8_filename);
1875 g_free (utf8_filename);
1880 #undef gtk_file_chooser_unselect_filename
1883 gtk_file_chooser_unselect_filename (GtkFileChooser *chooser,
1884 const char *filename)
1886 gchar *utf8_filename = g_locale_to_utf8 (filename, -1, NULL, NULL, NULL);
1888 gtk_file_chooser_unselect_filename_utf8 (chooser, utf8_filename);
1889 g_free (utf8_filename);
1892 #undef gtk_file_chooser_get_filenames
1895 gtk_file_chooser_get_filenames (GtkFileChooser *chooser)
1897 GSList *list = gtk_file_chooser_get_filenames_utf8 (chooser);
1898 GSList *rover = list;
1902 gchar *tem = (gchar *) rover->data;
1903 rover->data = g_locale_from_utf8 ((gchar *) rover->data, -1, NULL, NULL, NULL);
1905 rover = rover->next;
1911 #undef gtk_file_chooser_set_current_folder
1914 gtk_file_chooser_set_current_folder (GtkFileChooser *chooser,
1915 const gchar *filename)
1917 gchar *utf8_filename = g_locale_to_utf8 (filename, -1, NULL, NULL, NULL);
1918 gboolean retval = gtk_file_chooser_set_current_folder_utf8 (chooser, utf8_filename);
1920 g_free (utf8_filename);
1925 #undef gtk_file_chooser_get_current_folder
1928 gtk_file_chooser_get_current_folder (GtkFileChooser *chooser)
1930 gchar *utf8_folder = gtk_file_chooser_get_current_folder_utf8 (chooser);
1931 gchar *retval = g_locale_from_utf8 (utf8_folder, -1, NULL, NULL, NULL);
1933 g_free (utf8_folder);
1938 #undef gtk_file_chooser_get_preview_filename
1941 gtk_file_chooser_get_preview_filename (GtkFileChooser *chooser)
1943 char *utf8_filename = gtk_file_chooser_get_preview_filename_utf8 (chooser);
1944 char *retval = g_locale_from_utf8 (utf8_filename, -1, NULL, NULL, NULL);
1946 g_free (utf8_filename);
1951 #undef gtk_file_chooser_add_shortcut_folder
1954 gtk_file_chooser_add_shortcut_folder (GtkFileChooser *chooser,
1958 char *utf8_folder = g_locale_to_utf8 (folder, -1, NULL, NULL, NULL);
1960 gtk_file_chooser_add_shortcut_folder_utf8 (chooser, utf8_folder, error);
1962 g_free (utf8_folder);
1967 #undef gtk_file_chooser_remove_shortcut_folder
1970 gtk_file_chooser_remove_shortcut_folder (GtkFileChooser *chooser,
1974 char *utf8_folder = g_locale_to_utf8 (folder, -1, NULL, NULL, NULL);
1976 gtk_file_chooser_remove_shortcut_folder_utf8 (chooser, utf8_folder, error);
1978 g_free (utf8_folder);
1983 #undef gtk_file_chooser_list_shortcut_folders
1986 gtk_file_chooser_list_shortcut_folders (GtkFileChooser *chooser)
1988 GSList *list = gtk_file_chooser_list_shortcut_folders_utf8 (chooser);
1989 GSList *rover = list;
1993 gchar *tem = (gchar *) rover->data;
1994 rover->data = g_locale_from_utf8 ((gchar *) rover->data, -1, NULL, NULL, NULL);
1996 rover = rover->next;
2004 #define __GTK_FILE_CHOOSER_C__
2005 #include "gtkaliasdef.c"