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"
25 #include "gtktypebuiltins.h"
26 #include "gtkprivate.h"
27 #include "gtkmarshalers.h"
30 static void gtk_file_chooser_class_init (gpointer g_iface);
32 static GFile *gtk_file_chooser_get_file (GtkFileChooser *chooser);
35 gtk_file_chooser_get_type (void)
37 static GType file_chooser_type = 0;
39 if (!file_chooser_type)
41 file_chooser_type = g_type_register_static_simple (G_TYPE_INTERFACE,
43 sizeof (GtkFileChooserIface),
44 (GClassInitFunc) gtk_file_chooser_class_init,
47 g_type_interface_add_prerequisite (file_chooser_type, GTK_TYPE_WIDGET);
50 return file_chooser_type;
54 confirm_overwrite_accumulator (GSignalInvocationHint *ihint,
56 const GValue *handler_return,
59 gboolean continue_emission;
60 GtkFileChooserConfirmation conf;
62 conf = g_value_get_enum (handler_return);
63 g_value_set_enum (return_accu, conf);
64 continue_emission = (conf == GTK_FILE_CHOOSER_CONFIRMATION_CONFIRM);
66 return continue_emission;
70 gtk_file_chooser_class_init (gpointer g_iface)
72 GType iface_type = G_TYPE_FROM_INTERFACE (g_iface);
75 * GtkFileChooser::current-folder-changed
76 * @chooser: the object which received the signal.
78 * This signal is emitted when the current folder in a #GtkFileChooser
79 * changes. This can happen due to the user performing some action that
80 * changes folders, such as selecting a bookmark or visiting a folder on the
81 * file list. It can also happen as a result of calling a function to
82 * explicitly change the current folder in a file chooser.
84 * Normally you do not need to connect to this signal, unless you need to keep
85 * track of which folder a file chooser is showing.
87 * See also: gtk_file_chooser_set_current_folder(),
88 * gtk_file_chooser_get_current_folder(),
89 * gtk_file_chooser_set_current_folder_uri(),
90 * gtk_file_chooser_get_current_folder_uri().
92 g_signal_new (I_("current-folder-changed"),
95 G_STRUCT_OFFSET (GtkFileChooserIface, current_folder_changed),
97 g_cclosure_marshal_VOID__VOID,
101 * GtkFileChooser::selection-changed
102 * @chooser: the object which received the signal.
104 * This signal is emitted when there is a change in the set of selected files
105 * in a #GtkFileChooser. This can happen when the user modifies the selection
106 * with the mouse or the keyboard, or when explicitly calling functions to
107 * change the selection.
109 * Normally you do not need to connect to this signal, as it is easier to wait
110 * for the file chooser to finish running, and then to get the list of
111 * selected files using the functions mentioned below.
113 * See also: gtk_file_chooser_select_filename(),
114 * gtk_file_chooser_unselect_filename(), gtk_file_chooser_get_filename(),
115 * gtk_file_chooser_get_filenames(), gtk_file_chooser_select_uri(),
116 * gtk_file_chooser_unselect_uri(), gtk_file_chooser_get_uri(),
117 * gtk_file_chooser_get_uris().
119 g_signal_new (I_("selection-changed"),
122 G_STRUCT_OFFSET (GtkFileChooserIface, selection_changed),
124 g_cclosure_marshal_VOID__VOID,
128 * GtkFileChooser::update-preview
129 * @chooser: the object which received the signal.
131 * This signal is emitted when the preview in a file chooser should be
132 * regenerated. For example, this can happen when the currently selected file
133 * changes. You should use this signal if you want your file chooser to have
136 * Once you have installed a preview widget with
137 * gtk_file_chooser_set_preview_widget(), you should update it when this
138 * signal is emitted. You can use the functions
139 * gtk_file_chooser_get_preview_filename() or
140 * gtk_file_chooser_get_preview_uri() to get the name of the file to preview.
141 * Your widget may not be able to preview all kinds of files; your callback
142 * must call gtk_file_chooser_set_preview_widget_active() to inform the file
143 * chooser about whether the preview was generated successfully or not.
145 * Please see the example code in <xref linkend="gtkfilechooser-preview"/>.
147 * See also: gtk_file_chooser_set_preview_widget(),
148 * gtk_file_chooser_set_preview_widget_active(),
149 * gtk_file_chooser_set_use_preview_label(),
150 * gtk_file_chooser_get_preview_filename(),
151 * gtk_file_chooser_get_preview_uri().
153 g_signal_new (I_("update-preview"),
156 G_STRUCT_OFFSET (GtkFileChooserIface, update_preview),
158 g_cclosure_marshal_VOID__VOID,
162 * GtkFileChooser::file-activated
163 * @chooser: the object which received the signal.
165 * This signal is emitted when the user "activates" a file in the file
166 * chooser. This can happen by double-clicking on a file in the file list, or
167 * by pressing <keycap>Enter</keycap>.
169 * Normally you do not need to connect to this signal. It is used internally
170 * by #GtkFileChooserDialog to know when to activate the default button in the
173 * See also: gtk_file_chooser_get_filename(),
174 * gtk_file_chooser_get_filenames(), gtk_file_chooser_get_uri(),
175 * gtk_file_chooser_get_uris().
177 g_signal_new (I_("file-activated"),
180 G_STRUCT_OFFSET (GtkFileChooserIface, file_activated),
182 g_cclosure_marshal_VOID__VOID,
185 /* Documented in the docbook files */
186 g_signal_new (I_("confirm-overwrite"),
189 G_STRUCT_OFFSET (GtkFileChooserIface, confirm_overwrite),
190 confirm_overwrite_accumulator, NULL,
191 _gtk_marshal_ENUM__VOID,
192 GTK_TYPE_FILE_CHOOSER_CONFIRMATION, 0);
194 g_object_interface_install_property (g_iface,
195 g_param_spec_enum ("action",
197 P_("The type of operation that the file selector is performing"),
198 GTK_TYPE_FILE_CHOOSER_ACTION,
199 GTK_FILE_CHOOSER_ACTION_OPEN,
200 GTK_PARAM_READWRITE));
201 g_object_interface_install_property (g_iface,
202 g_param_spec_string ("file-system-backend",
203 P_("File System Backend"),
204 P_("Name of file system backend to use"),
206 GTK_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
207 g_object_interface_install_property (g_iface,
208 g_param_spec_object ("filter",
210 P_("The current filter for selecting which files are displayed"),
211 GTK_TYPE_FILE_FILTER,
212 GTK_PARAM_READWRITE));
213 g_object_interface_install_property (g_iface,
214 g_param_spec_boolean ("local-only",
216 P_("Whether the selected file(s) should be limited to local file: URLs"),
218 GTK_PARAM_READWRITE));
219 g_object_interface_install_property (g_iface,
220 g_param_spec_object ("preview-widget",
221 P_("Preview widget"),
222 P_("Application supplied widget for custom previews."),
224 GTK_PARAM_READWRITE));
225 g_object_interface_install_property (g_iface,
226 g_param_spec_boolean ("preview-widget-active",
227 P_("Preview Widget Active"),
228 P_("Whether the application supplied widget for custom previews should be shown."),
230 GTK_PARAM_READWRITE));
231 g_object_interface_install_property (g_iface,
232 g_param_spec_boolean ("use-preview-label",
233 P_("Use Preview Label"),
234 P_("Whether to display a stock label with the name of the previewed file."),
236 GTK_PARAM_READWRITE));
237 g_object_interface_install_property (g_iface,
238 g_param_spec_object ("extra-widget",
240 P_("Application supplied widget for extra options."),
242 GTK_PARAM_READWRITE));
243 g_object_interface_install_property (g_iface,
244 g_param_spec_boolean ("select-multiple",
245 P_("Select Multiple"),
246 P_("Whether to allow multiple files to be selected"),
248 GTK_PARAM_READWRITE));
250 g_object_interface_install_property (g_iface,
251 g_param_spec_boolean ("show-hidden",
253 P_("Whether the hidden files and folders should be displayed"),
255 GTK_PARAM_READWRITE));
258 * GtkFileChooser:do-overwrite-confirmation:
260 * Whether a file chooser in %GTK_FILE_CHOOSER_ACTION_SAVE mode
261 * will present an overwrite confirmation dialog if the user
262 * selects a file name that already exists.
266 g_object_interface_install_property (g_iface,
267 g_param_spec_boolean ("do-overwrite-confirmation",
268 P_("Do overwrite confirmation"),
269 P_("Whether a file chooser in save mode "
270 "will present an overwrite confirmation dialog "
273 GTK_PARAM_READWRITE));
277 * gtk_file_chooser_error_quark:
279 * Registers an error quark for #GtkFileChooser if necessary.
281 * Return value: The error quark used for #GtkFileChooser errors.
286 gtk_file_chooser_error_quark (void)
288 return g_quark_from_static_string ("gtk-file-chooser-error-quark");
292 * gtk_file_chooser_set_action:
293 * @chooser: a #GtkFileChooser
294 * @action: the action that the file selector is performing
296 * Sets the type of operation that the chooser is performing; the
297 * user interface is adapted to suit the selected action. For example,
298 * an option to create a new folder might be shown if the action is
299 * %GTK_FILE_CHOOSER_ACTION_SAVE but not if the action is
300 * %GTK_FILE_CHOOSER_ACTION_OPEN.
305 gtk_file_chooser_set_action (GtkFileChooser *chooser,
306 GtkFileChooserAction action)
308 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
310 g_object_set (chooser, "action", action, NULL);
314 * gtk_file_chooser_get_action:
315 * @chooser: a #GtkFileChooser
317 * Gets the type of operation that the file chooser is performing; see
318 * gtk_file_chooser_set_action().
320 * Return value: the action that the file selector is performing
325 gtk_file_chooser_get_action (GtkFileChooser *chooser)
327 GtkFileChooserAction action;
329 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
331 g_object_get (chooser, "action", &action, NULL);
337 * gtk_file_chooser_set_local_only:
338 * @chooser: a #GtkFileChooser
339 * @local_only: %TRUE if only local files can be selected
341 * Sets whether only local files can be selected in the
342 * file selector. If @local_only is %TRUE (the default),
343 * then the selected file are files are guaranteed to be
344 * accessible through the operating systems native file
345 * file system and therefore the application only
346 * needs to worry about the filename functions in
347 * #GtkFileChooser, like gtk_file_chooser_get_filename(),
348 * rather than the URI functions like
349 * gtk_file_chooser_get_uri(),
354 gtk_file_chooser_set_local_only (GtkFileChooser *chooser,
357 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
359 g_object_set (chooser, "local-only", local_only, NULL);
363 * gtk_file_chooser_get_local_only:
364 * @chooser: a #GtkFileChoosre
366 * Gets whether only local files can be selected in the
367 * file selector. See gtk_file_chooser_set_local_only()
369 * Return value: %TRUE if only local files can be selected.
374 gtk_file_chooser_get_local_only (GtkFileChooser *chooser)
378 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
380 g_object_get (chooser, "local-only", &local_only, NULL);
386 * gtk_file_chooser_set_select_multiple:
387 * @chooser: a #GtkFileChooser
388 * @select_multiple: %TRUE if multiple files can be selected.
390 * Sets whether multiple files can be selected in the file selector. This is
391 * only relevant if the action is set to be GTK_FILE_CHOOSER_ACTION_OPEN or
392 * GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER.
397 gtk_file_chooser_set_select_multiple (GtkFileChooser *chooser,
398 gboolean select_multiple)
400 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
402 g_object_set (chooser, "select-multiple", select_multiple, NULL);
406 * gtk_file_chooser_get_select_multiple:
407 * @chooser: a #GtkFileChooser
409 * Gets whether multiple files can be selected in the file
410 * selector. See gtk_file_chooser_set_select_multiple().
412 * Return value: %TRUE if multiple files can be selected.
417 gtk_file_chooser_get_select_multiple (GtkFileChooser *chooser)
419 gboolean select_multiple;
421 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
423 g_object_get (chooser, "select-multiple", &select_multiple, NULL);
425 return select_multiple;
429 * gtk_file_chooser_get_filename:
430 * @chooser: a #GtkFileChooser
432 * Gets the filename for the currently selected file in
433 * the file selector. If multiple files are selected,
434 * one of the filenames will be returned at random.
436 * If the file chooser is in folder mode, this function returns the selected
439 * Return value: The currently selected filename, or %NULL
440 * if no file is selected, or the selected file can't
441 * be represented with a local filename. Free with g_free().
446 gtk_file_chooser_get_filename (GtkFileChooser *chooser)
449 gchar *result = NULL;
451 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
453 file = gtk_file_chooser_get_file (chooser);
457 result = g_file_get_path (file);
458 g_object_unref (file);
465 * gtk_file_chooser_set_filename:
466 * @chooser: a #GtkFileChooser
467 * @filename: the filename to set as current
469 * Sets @filename as the current filename for the file chooser, by changing
470 * to the file's parent folder and actually selecting the file in list. If
471 * the @chooser is in #GTK_FILE_CHOOSER_ACTION_SAVE mode, the file's base name
472 * will also appear in the dialog's file name entry.
474 * If the file name isn't in the current folder of @chooser, then the current
475 * folder of @chooser will be changed to the folder containing @filename. This
476 * is equivalent to a sequence of gtk_file_chooser_unselect_all() followed by
477 * gtk_file_chooser_select_filename().
479 * Note that the file must exist, or nothing will be done except
480 * for the directory change.
482 * If you are implementing a <guimenuitem>File/Save As...</guimenuitem> dialog,
483 * you should use this function if you already have a file name to which the
484 * user may save; for example, when the user opens an existing file and then
485 * does <guimenuitem>File/Save As...</guimenuitem> on it. If you don't have
486 * a file name already — for example, if the user just created a new
487 * file and is saving it for the first time, do not call this function.
488 * Instead, use something similar to this:
490 * if (document_is_new)
492 * /* the user just created a new document */
493 * gtk_file_chooser_set_current_folder (chooser, default_folder_for_saving);
494 * gtk_file_chooser_set_current_name (chooser, "Untitled document");
498 * /* the user edited an existing document */
499 * gtk_file_chooser_set_filename (chooser, existing_filename);
503 * Return value: %TRUE if both the folder could be changed and the file was
504 * selected successfully, %FALSE otherwise.
509 gtk_file_chooser_set_filename (GtkFileChooser *chooser,
510 const gchar *filename)
512 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
514 gtk_file_chooser_unselect_all (chooser);
515 return gtk_file_chooser_select_filename (chooser, filename);
519 * gtk_file_chooser_select_filename:
520 * @chooser: a #GtkFileChooser
521 * @filename: the filename to select
523 * Selects a filename. If the file name isn't in the current
524 * folder of @chooser, then the current folder of @chooser will
525 * be changed to the folder containing @filename.
527 * Return value: %TRUE if both the folder could be changed and the file was
528 * selected successfully, %FALSE otherwise.
533 gtk_file_chooser_select_filename (GtkFileChooser *chooser,
534 const gchar *filename)
539 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
540 g_return_val_if_fail (filename != NULL, FALSE);
542 file = g_file_new_for_path (filename);
543 result = _gtk_file_chooser_select_file (chooser, file, NULL);
544 g_object_unref (file);
550 * gtk_file_chooser_unselect_filename:
551 * @chooser: a #GtkFileChooser
552 * @filename: the filename to unselect
554 * Unselects a currently selected filename. If the filename
555 * is not in the current directory, does not exist, or
556 * is otherwise not currently selected, does nothing.
561 gtk_file_chooser_unselect_filename (GtkFileChooser *chooser,
562 const char *filename)
566 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
567 g_return_if_fail (filename != NULL);
569 file = g_file_new_for_path (filename);
570 _gtk_file_chooser_unselect_file (chooser, file);
571 g_object_unref (file);
574 /* Converts a list of GFile* to a list of strings using the specified function */
576 files_to_strings (GSList *files,
577 gchar * (*convert_func) (GFile *file))
583 for (; files; files = files->next)
589 string = (* convert_func) (file);
592 strings = g_slist_prepend (strings, string);
595 return g_slist_reverse (strings);
599 * gtk_file_chooser_get_filenames:
600 * @chooser: a #GtkFileChooser
602 * Lists all the selected files and subfolders in the current folder of
603 * @chooser. The returned names are full absolute paths. If files in the current
604 * folder cannot be represented as local filenames they will be ignored. (See
605 * gtk_file_chooser_get_uris())
607 * Return value: a #GSList containing the filenames of all selected
608 * files and subfolders in the current folder. Free the returned list
609 * with g_slist_free(), and the filenames with g_free().
614 gtk_file_chooser_get_filenames (GtkFileChooser *chooser)
616 GSList *files, *result;
618 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
620 files = _gtk_file_chooser_get_files (chooser);
622 result = files_to_strings (files, g_file_get_path);
623 g_slist_foreach (files, (GFunc) g_object_unref, NULL);
624 g_slist_free (files);
630 * gtk_file_chooser_set_current_folder:
631 * @chooser: a #GtkFileChooser
632 * @filename: the full path of the new current folder
634 * Sets the current folder for @chooser from a local filename.
635 * The user will be shown the full contents of the current folder,
636 * plus user interface elements for navigating to other folders.
638 * Return value: %TRUE if the folder could be changed successfully, %FALSE
644 gtk_file_chooser_set_current_folder (GtkFileChooser *chooser,
645 const gchar *filename)
650 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
651 g_return_val_if_fail (filename != NULL, FALSE);
653 file = g_file_new_for_path (filename);
654 result = _gtk_file_chooser_set_current_folder_file (chooser, file, NULL);
655 g_object_unref (file);
661 * gtk_file_chooser_get_current_folder:
662 * @chooser: a #GtkFileChooser
664 * Gets the current folder of @chooser as a local filename.
665 * See gtk_file_chooser_set_current_folder().
667 * Note that this is the folder that the file chooser is currently displaying
668 * (e.g. "/home/username/Documents"), which is <emphasis>not the same</emphasis>
669 * as the currently-selected folder if the chooser is in
670 * #GTK_FILE_CHOOSER_SELECT_FOLDER mode
671 * (e.g. "/home/username/Documents/selected-folder/". To get the
672 * currently-selected folder in that mode, use gtk_file_chooser_get_uri() as the
673 * usual way to get the selection.
675 * Return value: the full path of the current folder, or %NULL if the current
676 * path cannot be represented as a local filename. Free with g_free(). This
677 * function will also return %NULL if the file chooser was unable to load the
678 * last folder that was requested from it; for example, as would be for calling
679 * gtk_file_chooser_set_current_folder() on a nonexistent folder.
684 gtk_file_chooser_get_current_folder (GtkFileChooser *chooser)
689 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
691 file = _gtk_file_chooser_get_current_folder_file (chooser);
695 filename = g_file_get_path (file);
696 g_object_unref (file);
702 * gtk_file_chooser_set_current_name:
703 * @chooser: a #GtkFileChooser
704 * @name: the filename to use, as a UTF-8 string
706 * Sets the current name in the file selector, as if entered
707 * by the user. Note that the name passed in here is a UTF-8
708 * string rather than a filename. This function is meant for
709 * such uses as a suggested name in a "Save As..." dialog.
711 * If you want to preselect a particular existing file, you should use
712 * gtk_file_chooser_set_filename() or gtk_file_chooser_set_uri() instead.
713 * Please see the documentation for those functions for an example of using
714 * gtk_file_chooser_set_current_name() as well.
719 gtk_file_chooser_set_current_name (GtkFileChooser *chooser,
722 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
723 g_return_if_fail (name != NULL);
725 GTK_FILE_CHOOSER_GET_IFACE (chooser)->set_current_name (chooser, name);
729 * gtk_file_chooser_get_uri:
730 * @chooser: a #GtkFileChooser
732 * Gets the URI for the currently selected file in
733 * the file selector. If multiple files are selected,
734 * one of the filenames will be returned at random.
736 * If the file chooser is in folder mode, this function returns the selected
739 * Return value: The currently selected URI, or %NULL
740 * if no file is selected. Free with g_free()
745 gtk_file_chooser_get_uri (GtkFileChooser *chooser)
748 gchar *result = NULL;
750 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
752 file = gtk_file_chooser_get_file (chooser);
755 result = g_file_get_uri (file);
756 g_object_unref (file);
763 * gtk_file_chooser_set_uri:
764 * @chooser: a #GtkFileChooser
765 * @uri: the URI to set as current
767 * Sets the file referred to by @uri as the current file for the file chooser,
768 * by changing to the URI's parent folder and actually selecting the URI in the
769 * list. If the @chooser is #GTK_FILE_CHOOSER_ACTION_SAVE mode, the URI's base
770 * name will also appear in the dialog's file name entry.
772 * If the URI isn't in the current folder of @chooser, then the current folder
773 * of @chooser will be changed to the folder containing @uri. This is equivalent
774 * to a sequence of gtk_file_chooser_unselect_all() followed by
775 * gtk_file_chooser_select_uri().
777 * Note that the URI must exist, or nothing will be done except for the
779 * If you are implementing a <guimenuitem>File/Save As...</guimenuitem> dialog,
780 * you should use this function if you already have a file name to which the
781 * user may save; for example, when the user opens an existing file and then
782 * does <guimenuitem>File/Save As...</guimenuitem> on it. If you don't have
783 * a file name already — for example, if the user just created a new
784 * file and is saving it for the first time, do not call this function.
785 * Instead, use something similar to this:
787 * if (document_is_new)
789 * /* the user just created a new document */
790 * gtk_file_chooser_set_current_folder_uri (chooser, default_folder_for_saving);
791 * gtk_file_chooser_set_current_name (chooser, "Untitled document");
795 * /* the user edited an existing document */
796 * gtk_file_chooser_set_uri (chooser, existing_uri);
800 * Return value: %TRUE if both the folder could be changed and the URI was
801 * selected successfully, %FALSE otherwise.
806 gtk_file_chooser_set_uri (GtkFileChooser *chooser,
809 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
811 gtk_file_chooser_unselect_all (chooser);
812 return gtk_file_chooser_select_uri (chooser, uri);
816 * gtk_file_chooser_select_uri:
817 * @chooser: a #GtkFileChooser
818 * @uri: the URI to select
820 * Selects the file to by @uri. If the URI doesn't refer to a
821 * file in the current folder of @chooser, then the current folder of
822 * @chooser will be changed to the folder containing @filename.
824 * Return value: %TRUE if both the folder could be changed and the URI was
825 * selected successfully, %FALSE otherwise.
830 gtk_file_chooser_select_uri (GtkFileChooser *chooser,
836 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
837 g_return_val_if_fail (uri != NULL, FALSE);
839 file = g_file_new_for_uri (uri);
840 result = _gtk_file_chooser_select_file (chooser, file, NULL);
841 g_object_unref (file);
847 * gtk_file_chooser_unselect_uri:
848 * @chooser: a #GtkFileChooser
849 * @uri: the URI to unselect
851 * Unselects the file referred to by @uri. If the file
852 * is not in the current directory, does not exist, or
853 * is otherwise not currently selected, does nothing.
858 gtk_file_chooser_unselect_uri (GtkFileChooser *chooser,
863 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
864 g_return_if_fail (uri != NULL);
866 file = g_file_new_for_uri (uri);
867 _gtk_file_chooser_unselect_file (chooser, file);
868 g_object_unref (file);
872 * gtk_file_chooser_select_all:
873 * @chooser: a #GtkFileChooser
875 * Selects all the files in the current folder of a file chooser.
880 gtk_file_chooser_select_all (GtkFileChooser *chooser)
882 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
884 GTK_FILE_CHOOSER_GET_IFACE (chooser)->select_all (chooser);
888 * gtk_file_chooser_unselect_all:
889 * @chooser: a #GtkFileChooser
891 * Unselects all the files in the current folder of a file chooser.
896 gtk_file_chooser_unselect_all (GtkFileChooser *chooser)
899 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
901 GTK_FILE_CHOOSER_GET_IFACE (chooser)->unselect_all (chooser);
905 * gtk_file_chooser_get_uris:
906 * @chooser: a #GtkFileChooser
908 * Lists all the selected files and subfolders in the current folder of
909 * @chooser. The returned names are full absolute URIs.
911 * Return value: a #GSList containing the URIs of all selected
912 * files and subfolders in the current folder. Free the returned list
913 * with g_slist_free(), and the filenames with g_free().
918 gtk_file_chooser_get_uris (GtkFileChooser *chooser)
920 GSList *files, *result;
922 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
924 files = _gtk_file_chooser_get_files (chooser);
926 result = files_to_strings (files, g_file_get_uri);
927 g_slist_foreach (files, (GFunc) g_object_unref, NULL);
928 g_slist_free (files);
934 * gtk_file_chooser_set_current_folder_uri:
935 * @chooser: a #GtkFileChooser
936 * @uri: the URI for the new current folder
938 * Sets the current folder for @chooser from an URI.
939 * The user will be shown the full contents of the current folder,
940 * plus user interface elements for navigating to other folders.
942 * Return value: %TRUE if the folder could be changed successfully, %FALSE
948 gtk_file_chooser_set_current_folder_uri (GtkFileChooser *chooser,
954 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
955 g_return_val_if_fail (uri != NULL, FALSE);
957 file = g_file_new_for_uri (uri);
958 result = _gtk_file_chooser_set_current_folder_file (chooser, file, NULL);
959 g_object_unref (file);
965 * gtk_file_chooser_get_current_folder_uri:
966 * @chooser: a #GtkFileChooser
968 * Gets the current folder of @chooser as an URI.
969 * See gtk_file_chooser_set_current_folder_uri().
971 * Note that this is the folder that the file chooser is currently displaying
972 * (e.g. "file:///home/username/Documents"), which is <emphasis>not the same</emphasis>
973 * as the currently-selected folder if the chooser is in
974 * #GTK_FILE_CHOOSER_SELECT_FOLDER mode
975 * (e.g. "file:///home/username/Documents/selected-folder/". To get the
976 * currently-selected folder in that mode, use gtk_file_chooser_get_uri() as the
977 * usual way to get the selection.
979 * Return value: the URI for the current folder. Free with g_free(). This
980 * function will also return %NULL if the file chooser was unable to load the
981 * last folder that was requested from it; for example, as would be for calling
982 * gtk_file_chooser_set_current_folder_uri() on a nonexistent folder.
987 gtk_file_chooser_get_current_folder_uri (GtkFileChooser *chooser)
992 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
994 file = _gtk_file_chooser_get_current_folder_file (chooser);
998 uri = g_file_get_uri (file);
999 g_object_unref (file);
1005 * _gtk_file_chooser_set_current_folder_file:
1006 * @chooser: a #GtkFileChooser
1007 * @file: the #GFile for the new folder
1008 * @error: location to store error, or %NULL.
1010 * Sets the current folder for @chooser from a #GFile.
1011 * Internal function, see gtk_file_chooser_set_current_folder_uri().
1013 * Return value: %TRUE if the folder could be changed successfully, %FALSE
1019 _gtk_file_chooser_set_current_folder_file (GtkFileChooser *chooser,
1023 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1024 g_return_val_if_fail (G_IS_FILE (file), FALSE);
1025 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
1027 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->set_current_folder (chooser, file, error);
1031 * _gtk_file_chooser_get_current_folder_file:
1032 * @chooser: a #GtkFileChooser
1034 * Gets the current folder of @chooser as #GFile.
1035 * See gtk_file_chooser_get_current_folder_uri().
1037 * Return value: the #GFile for the current folder.
1042 _gtk_file_chooser_get_current_folder_file (GtkFileChooser *chooser)
1044 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1046 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_current_folder (chooser);
1050 * _gtk_file_chooser_select_file:
1051 * @chooser: a #GtkFileChooser
1052 * @file: the file to select
1053 * @error: location to store error, or %NULL
1055 * Selects the file referred to by @path. An internal function. See
1056 * _gtk_file_chooser_select_uri().
1058 * Return value: %TRUE if both the folder could be changed and the path was
1059 * selected successfully, %FALSE otherwise.
1064 _gtk_file_chooser_select_file (GtkFileChooser *chooser,
1068 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1069 g_return_val_if_fail (G_IS_FILE (file), FALSE);
1070 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
1072 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->select_file (chooser, file, error);
1076 * _gtk_file_chooser_unselect_path:
1077 * @chooser: a #GtkFileChooser
1078 * @path: the filename to path
1080 * Unselects the file referred to by @path. An internal
1081 * function. See _gtk_file_chooser_unselect_uri().
1086 _gtk_file_chooser_unselect_file (GtkFileChooser *chooser,
1089 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1090 g_return_if_fail (G_IS_FILE (file));
1092 GTK_FILE_CHOOSER_GET_IFACE (chooser)->unselect_file (chooser, file);
1096 * _gtk_file_chooser_get_files:
1097 * @chooser: a #GtkFileChooser
1099 * Lists all the selected files and subfolders in the current folder of @chooser
1100 * as #GFile. An internal function, see gtk_file_chooser_get_uris().
1102 * Return value: a #GSList containing a #GFile for each selected
1103 * file and subfolder in the current folder. Free the returned list
1104 * with g_slist_free(), and the files with g_object_unref().
1109 _gtk_file_chooser_get_files (GtkFileChooser *chooser)
1111 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1113 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_files (chooser);
1117 gtk_file_chooser_get_file (GtkFileChooser *chooser)
1120 GFile *result = NULL;
1122 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1124 list = _gtk_file_chooser_get_files (chooser);
1127 result = list->data;
1128 list = g_slist_delete_link (list, list);
1130 g_slist_foreach (list, (GFunc) g_object_unref, NULL);
1131 g_slist_free (list);
1138 * _gtk_file_chooser_get_file_system:
1139 * @chooser: a #GtkFileChooser
1141 * Gets the #GtkFileSystem of @chooser; this is an internal
1142 * implementation detail, used for conversion between paths
1143 * and filenames and URIs.
1145 * Return value: the file system for @chooser.
1150 _gtk_file_chooser_get_file_system (GtkFileChooser *chooser)
1152 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1154 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_file_system (chooser);
1160 * gtk_file_chooser_set_preview_widget:
1161 * @chooser: a #GtkFileChooser
1162 * @preview_widget: widget for displaying preview.
1164 * Sets an application-supplied widget to use to display a custom preview
1165 * of the currently selected file. To implement a preview, after setting the
1166 * preview widget, you connect to the ::update-preview
1167 * signal, and call gtk_file_chooser_get_preview_filename() or
1168 * gtk_file_chooser_get_preview_uri() on each change. If you can
1169 * display a preview of the new file, update your widget and
1170 * set the preview active using gtk_file_chooser_set_preview_widget_active().
1171 * Otherwise, set the preview inactive.
1173 * When there is no application-supplied preview widget, or the
1174 * application-supplied preview widget is not active, the file chooser
1175 * may display an internally generated preview of the current file or
1176 * it may display no preview at all.
1181 gtk_file_chooser_set_preview_widget (GtkFileChooser *chooser,
1182 GtkWidget *preview_widget)
1184 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1186 g_object_set (chooser, "preview-widget", preview_widget, NULL);
1190 * gtk_file_chooser_get_preview_widget:
1191 * @chooser: a #GtkFileChooser
1193 * Gets the current preview widget; see
1194 * gtk_file_chooser_set_preview_widget().
1196 * Return value: the current preview widget, or %NULL
1201 gtk_file_chooser_get_preview_widget (GtkFileChooser *chooser)
1203 GtkWidget *preview_widget;
1205 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1207 g_object_get (chooser, "preview-widget", &preview_widget, NULL);
1209 /* Horrid hack; g_object_get() refs returned objects but
1210 * that contradicts the memory management conventions
1214 g_object_unref (preview_widget);
1216 return preview_widget;
1220 * gtk_file_chooser_set_preview_widget_active:
1221 * @chooser: a #GtkFileChooser
1222 * @active: whether to display the user-specified preview widget
1224 * Sets whether the preview widget set by
1225 * gtk_file_chooser_set_preview_widget() should be shown for the
1226 * current filename. When @active is set to false, the file chooser
1227 * may display an internally generated preview of the current file
1228 * or it may display no preview at all. See
1229 * gtk_file_chooser_set_preview_widget() for more details.
1234 gtk_file_chooser_set_preview_widget_active (GtkFileChooser *chooser,
1237 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1239 g_object_set (chooser, "preview-widget-active", active, NULL);
1243 * gtk_file_chooser_get_preview_widget_active:
1244 * @chooser: a #GtkFileChooser
1246 * Gets whether the preview widget set by gtk_file_chooser_set_preview_widget()
1247 * should be shown for the current filename. See
1248 * gtk_file_chooser_set_preview_widget_active().
1250 * Return value: %TRUE if the preview widget is active for the current filename.
1255 gtk_file_chooser_get_preview_widget_active (GtkFileChooser *chooser)
1259 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1261 g_object_get (chooser, "preview-widget-active", &active, NULL);
1267 * gtk_file_chooser_set_use_preview_label:
1268 * @chooser: a #GtkFileChooser
1269 * @use_label: whether to display a stock label with the name of the previewed file
1271 * Sets whether the file chooser should display a stock label with the name of
1272 * the file that is being previewed; the default is %TRUE. Applications that
1273 * want to draw the whole preview area themselves should set this to %FALSE and
1274 * display the name themselves in their preview widget.
1276 * See also: gtk_file_chooser_set_preview_widget()
1281 gtk_file_chooser_set_use_preview_label (GtkFileChooser *chooser,
1284 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1286 g_object_set (chooser, "use-preview-label", use_label, NULL);
1290 * gtk_file_chooser_get_use_preview_label:
1291 * @chooser: a #GtkFileChooser
1293 * Gets whether a stock label should be drawn with the name of the previewed
1294 * file. See gtk_file_chooser_set_use_preview_label().
1296 * Return value: %TRUE if the file chooser is set to display a label with the
1297 * name of the previewed file, %FALSE otherwise.
1300 gtk_file_chooser_get_use_preview_label (GtkFileChooser *chooser)
1304 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1306 g_object_get (chooser, "use-preview-label", &use_label, NULL);
1312 * gtk_file_chooser_get_preview_file:
1313 * @chooser: a #GtkFileChooser
1315 * Gets the filename that should be previewed in a custom preview
1316 * Internal function, see gtk_file_chooser_get_preview_uri().
1318 * Return value: the #GFile for the file to preview, or %NULL if no file
1319 * is selected. Free with gtk_file_path_free().
1324 _gtk_file_chooser_get_preview_file (GtkFileChooser *chooser)
1326 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1328 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_preview_file (chooser);
1332 * _gtk_file_chooser_add_shortcut_folder:
1333 * @chooser: a #GtkFileChooser
1334 * @file: file for the folder to add
1335 * @error: location to store error, or %NULL
1337 * Adds a folder to be displayed with the shortcut folders in a file chooser.
1338 * Internal function, see gtk_file_chooser_add_shortcut_folder().
1340 * Return value: %TRUE if the folder could be added successfully, %FALSE
1346 _gtk_file_chooser_add_shortcut_folder (GtkFileChooser *chooser,
1350 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1351 g_return_val_if_fail (G_IS_FILE (file), FALSE);
1353 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_shortcut_folder (chooser, file, error);
1357 * _gtk_file_chooser_remove_shortcut_folder:
1358 * @chooser: a #GtkFileChooser
1359 * @file: file for the folder to remove
1360 * @error: location to store error, or %NULL
1362 * Removes a folder from the shortcut folders in a file chooser. Internal
1363 * function, see gtk_file_chooser_remove_shortcut_folder().
1365 * Return value: %TRUE if the folder could be removed successfully, %FALSE
1371 _gtk_file_chooser_remove_shortcut_folder (GtkFileChooser *chooser,
1375 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1376 g_return_val_if_fail (G_IS_FILE (file), FALSE);
1378 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_shortcut_folder (chooser, file, error);
1382 * gtk_file_chooser_get_preview_filename:
1383 * @chooser: a #GtkFileChooser
1385 * Gets the filename that should be previewed in a custom preview
1386 * widget. See gtk_file_chooser_set_preview_widget().
1388 * Return value: the filename to preview, or %NULL if no file
1389 * is selected, or if the selected file cannot be represented
1390 * as a local filename. Free with g_free()
1395 gtk_file_chooser_get_preview_filename (GtkFileChooser *chooser)
1398 gchar *result = NULL;
1400 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1402 file =_gtk_file_chooser_get_preview_file (chooser);
1405 result = g_file_get_path (file);
1406 g_object_unref (file);
1413 * gtk_file_chooser_get_preview_uri:
1414 * @chooser: a #GtkFileChooser
1416 * Gets the URI that should be previewed in a custom preview
1417 * widget. See gtk_file_chooser_set_preview_widget().
1419 * Return value: the URI for the file to preview, or %NULL if no file is
1420 * selected. Free with g_free().
1425 gtk_file_chooser_get_preview_uri (GtkFileChooser *chooser)
1428 gchar *result = NULL;
1430 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1432 file = _gtk_file_chooser_get_preview_file (chooser);
1435 result = g_file_get_uri (file);
1436 g_object_unref (file);
1443 * gtk_file_chooser_set_extra_widget:
1444 * @chooser: a #GtkFileChooser
1445 * @extra_widget: widget for extra options
1447 * Sets an application-supplied widget to provide extra options to the user.
1452 gtk_file_chooser_set_extra_widget (GtkFileChooser *chooser,
1453 GtkWidget *extra_widget)
1455 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1457 g_object_set (chooser, "extra-widget", extra_widget, NULL);
1461 * gtk_file_chooser_get_extra_widget:
1462 * @chooser: a #GtkFileChooser
1464 * Gets the current preview widget; see
1465 * gtk_file_chooser_set_extra_widget().
1467 * Return value: the current extra widget, or %NULL
1472 gtk_file_chooser_get_extra_widget (GtkFileChooser *chooser)
1474 GtkWidget *extra_widget;
1476 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1478 g_object_get (chooser, "extra-widget", &extra_widget, NULL);
1480 /* Horrid hack; g_object_get() refs returned objects but
1481 * that contradicts the memory management conventions
1485 g_object_unref (extra_widget);
1487 return extra_widget;
1491 * gtk_file_chooser_add_filter:
1492 * @chooser: a #GtkFileChooser
1493 * @filter: a #GtkFileFilter
1495 * Adds @filter to the list of filters that the user can select between.
1496 * When a filter is selected, only files that are passed by that
1497 * filter are displayed.
1499 * Note that the @chooser takes ownership of the filter, so you have to
1500 * ref and sink it if you want to keep a reference.
1505 gtk_file_chooser_add_filter (GtkFileChooser *chooser,
1506 GtkFileFilter *filter)
1508 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1510 GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_filter (chooser, filter);
1514 * gtk_file_chooser_remove_filter:
1515 * @chooser: a #GtkFileChooser
1516 * @filter: a #GtkFileFilter
1518 * Removes @filter from the list of filters that the user can select between.
1523 gtk_file_chooser_remove_filter (GtkFileChooser *chooser,
1524 GtkFileFilter *filter)
1526 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1528 GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_filter (chooser, filter);
1532 * gtk_file_chooser_list_filters:
1533 * @chooser: a #GtkFileChooser
1535 * Lists the current set of user-selectable filters; see
1536 * gtk_file_chooser_add_filter(), gtk_file_chooser_remove_filter().
1538 * Return value: a #GSList containing the current set of
1539 * user selectable filters. The contents of the list are
1540 * owned by GTK+, but you must free the list itself with
1541 * g_slist_free() when you are done with it.
1546 gtk_file_chooser_list_filters (GtkFileChooser *chooser)
1548 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1550 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->list_filters (chooser);
1554 * gtk_file_chooser_set_filter:
1555 * @chooser: a #GtkFileChooser
1556 * @filter: a #GtkFileFilter
1558 * Sets the current filter; only the files that pass the
1559 * filter will be displayed. If the user-selectable list of filters
1560 * is non-empty, then the filter should be one of the filters
1561 * in that list. Setting the current filter when the list of
1562 * filters is empty is useful if you want to restrict the displayed
1563 * set of files without letting the user change it.
1568 gtk_file_chooser_set_filter (GtkFileChooser *chooser,
1569 GtkFileFilter *filter)
1571 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1572 g_return_if_fail (GTK_IS_FILE_FILTER (filter));
1574 g_object_set (chooser, "filter", filter, NULL);
1578 * gtk_file_chooser_get_filter:
1579 * @chooser: a #GtkFileChooser
1581 * Gets the current filter; see gtk_file_chooser_set_filter().
1583 * Return value: the current filter, or %NULL
1588 gtk_file_chooser_get_filter (GtkFileChooser *chooser)
1590 GtkFileFilter *filter;
1592 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1594 g_object_get (chooser, "filter", &filter, NULL);
1595 /* Horrid hack; g_object_get() refs returned objects but
1596 * that contradicts the memory management conventions
1600 g_object_unref (filter);
1606 * gtk_file_chooser_add_shortcut_folder:
1607 * @chooser: a #GtkFileChooser
1608 * @folder: filename of the folder to add
1609 * @error: location to store error, or %NULL
1611 * Adds a folder to be displayed with the shortcut folders in a file chooser.
1612 * Note that shortcut folders do not get saved, as they are provided by the
1613 * application. For example, you can use this to add a
1614 * "/usr/share/mydrawprogram/Clipart" folder to the volume list.
1616 * Return value: %TRUE if the folder could be added successfully, %FALSE
1617 * otherwise. In the latter case, the @error will be set as appropriate.
1622 gtk_file_chooser_add_shortcut_folder (GtkFileChooser *chooser,
1629 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1630 g_return_val_if_fail (folder != NULL, FALSE);
1632 file = g_file_new_for_path (folder);
1633 result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_shortcut_folder (chooser, file, error);
1634 g_object_unref (file);
1640 * gtk_file_chooser_remove_shortcut_folder:
1641 * @chooser: a #GtkFileChooser
1642 * @folder: filename of the folder to remove
1643 * @error: location to store error, or %NULL
1645 * Removes a folder from a file chooser's list of shortcut folders.
1647 * Return value: %TRUE if the operation succeeds, %FALSE otherwise.
1648 * In the latter case, the @error will be set as appropriate.
1650 * See also: gtk_file_chooser_add_shortcut_folder()
1655 gtk_file_chooser_remove_shortcut_folder (GtkFileChooser *chooser,
1662 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1663 g_return_val_if_fail (folder != NULL, FALSE);
1665 file = g_file_new_for_path (folder);
1666 result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_shortcut_folder (chooser, file, error);
1667 g_object_unref (file);
1673 * gtk_file_chooser_list_shortcut_folders:
1674 * @chooser: a #GtkFileChooser
1676 * Queries the list of shortcut folders in the file chooser, as set by
1677 * gtk_file_chooser_add_shortcut_folder().
1679 * Return value: A list of folder filenames, or %NULL if there are no shortcut
1680 * folders. Free the returned list with g_slist_free(), and the filenames with
1686 gtk_file_chooser_list_shortcut_folders (GtkFileChooser *chooser)
1691 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1693 folders = GTK_FILE_CHOOSER_GET_IFACE (chooser)->list_shortcut_folders (chooser);
1695 result = files_to_strings (folders, g_file_get_path);
1696 g_slist_foreach (folders, (GFunc) g_object_unref, NULL);
1697 g_slist_free (folders);
1703 * gtk_file_chooser_add_shortcut_folder_uri:
1704 * @chooser: a #GtkFileChooser
1705 * @uri: URI of the folder to add
1706 * @error: location to store error, or %NULL
1708 * Adds a folder URI to be displayed with the shortcut folders in a file
1709 * chooser. Note that shortcut folders do not get saved, as they are provided
1710 * by the application. For example, you can use this to add a
1711 * "file:///usr/share/mydrawprogram/Clipart" folder to the volume list.
1713 * Return value: %TRUE if the folder could be added successfully, %FALSE
1714 * otherwise. In the latter case, the @error will be set as appropriate.
1719 gtk_file_chooser_add_shortcut_folder_uri (GtkFileChooser *chooser,
1726 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1727 g_return_val_if_fail (uri != NULL, FALSE);
1729 file = g_file_new_for_uri (uri);
1730 result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_shortcut_folder (chooser, file, error);
1731 g_object_unref (file);
1737 * gtk_file_chooser_remove_shortcut_folder_uri:
1738 * @chooser: a #GtkFileChooser
1739 * @uri: URI of the folder to remove
1740 * @error: location to store error, or %NULL
1742 * Removes a folder URI from a file chooser's list of shortcut folders.
1744 * Return value: %TRUE if the operation succeeds, %FALSE otherwise.
1745 * In the latter case, the @error will be set as appropriate.
1747 * See also: gtk_file_chooser_add_shortcut_folder_uri()
1752 gtk_file_chooser_remove_shortcut_folder_uri (GtkFileChooser *chooser,
1759 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1760 g_return_val_if_fail (uri != NULL, FALSE);
1762 file = g_file_new_for_uri (uri);
1763 result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_shortcut_folder (chooser, file, error);
1764 g_object_unref (file);
1770 * gtk_file_chooser_list_shortcut_folder_uris:
1771 * @chooser: a #GtkFileChooser
1773 * Queries the list of shortcut folders in the file chooser, as set by
1774 * gtk_file_chooser_add_shortcut_folder_uri().
1776 * Return value: A list of folder URIs, or %NULL if there are no shortcut
1777 * folders. Free the returned list with g_slist_free(), and the URIs with
1783 gtk_file_chooser_list_shortcut_folder_uris (GtkFileChooser *chooser)
1788 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1790 folders = GTK_FILE_CHOOSER_GET_IFACE (chooser)->list_shortcut_folders (chooser);
1792 result = files_to_strings (folders, g_file_get_uri);
1793 g_slist_foreach (folders, (GFunc) g_object_unref, NULL);
1794 g_slist_free (folders);
1801 * gtk_file_chooser_set_show_hidden:
1802 * @chooser: a #GtkFileChooser
1803 * @show_hidden: %TRUE if hidden files and folders should be displayed.
1805 * Sets whether hidden files and folders are displayed in the file selector.
1810 gtk_file_chooser_set_show_hidden (GtkFileChooser *chooser,
1811 gboolean show_hidden)
1813 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1815 g_object_set (chooser, "show-hidden", show_hidden, NULL);
1819 * gtk_file_chooser_get_show_hidden:
1820 * @chooser: a #GtkFileChooser
1822 * Gets whether hidden files and folders are displayed in the file selector.
1823 * See gtk_file_chooser_set_show_hidden().
1825 * Return value: %TRUE if hidden files and folders are displayed.
1830 gtk_file_chooser_get_show_hidden (GtkFileChooser *chooser)
1832 gboolean show_hidden;
1834 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1836 g_object_get (chooser, "show-hidden", &show_hidden, NULL);
1842 * gtk_file_chooser_set_do_overwrite_confirmation:
1843 * @chooser: a #GtkFileChooser
1844 * @do_overwrite_confirmation: whether to confirm overwriting in save mode
1846 * Sets whether a file chooser in GTK_FILE_CHOOSER_ACTION_SAVE mode will present
1847 * a confirmation dialog if the user types a file name that already exists. This
1848 * is %FALSE by default.
1850 * Regardless of this setting, the @chooser will emit the "confirm-overwrite"
1851 * signal when appropriate.
1853 * If all you need is the stock confirmation dialog, set this property to %TRUE.
1854 * You can override the way confirmation is done by actually handling the
1855 * "confirm-overwrite" signal; please refer to its documentation for the
1861 gtk_file_chooser_set_do_overwrite_confirmation (GtkFileChooser *chooser,
1862 gboolean do_overwrite_confirmation)
1864 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1866 g_object_set (chooser, "do-overwrite-confirmation", do_overwrite_confirmation, NULL);
1870 * gtk_file_chooser_get_do_overwrite_confirmation:
1871 * @chooser: a #GtkFileChooser
1873 * Queries whether a file chooser is set to confirm for overwriting when the user
1874 * types a file name that already exists.
1876 * Return value: %TRUE if the file chooser will present a confirmation dialog;
1882 gtk_file_chooser_get_do_overwrite_confirmation (GtkFileChooser *chooser)
1884 gboolean do_overwrite_confirmation;
1886 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1888 g_object_get (chooser, "do-overwrite-confirmation", &do_overwrite_confirmation, NULL);
1890 return do_overwrite_confirmation;
1895 /* DLL ABI stability backward compatibility versions */
1897 #undef gtk_file_chooser_get_filename
1900 gtk_file_chooser_get_filename (GtkFileChooser *chooser)
1902 gchar *utf8_filename = gtk_file_chooser_get_filename_utf8 (chooser);
1903 gchar *retval = g_locale_from_utf8 (utf8_filename, -1, NULL, NULL, NULL);
1905 g_free (utf8_filename);
1910 #undef gtk_file_chooser_set_filename
1913 gtk_file_chooser_set_filename (GtkFileChooser *chooser,
1914 const gchar *filename)
1916 gchar *utf8_filename = g_locale_to_utf8 (filename, -1, NULL, NULL, NULL);
1917 gboolean retval = gtk_file_chooser_set_filename_utf8 (chooser, utf8_filename);
1919 g_free (utf8_filename);
1924 #undef gtk_file_chooser_select_filename
1927 gtk_file_chooser_select_filename (GtkFileChooser *chooser,
1928 const gchar *filename)
1930 gchar *utf8_filename = g_locale_to_utf8 (filename, -1, NULL, NULL, NULL);
1931 gboolean retval = gtk_file_chooser_select_filename_utf8 (chooser, utf8_filename);
1933 g_free (utf8_filename);
1938 #undef gtk_file_chooser_unselect_filename
1941 gtk_file_chooser_unselect_filename (GtkFileChooser *chooser,
1942 const char *filename)
1944 gchar *utf8_filename = g_locale_to_utf8 (filename, -1, NULL, NULL, NULL);
1946 gtk_file_chooser_unselect_filename_utf8 (chooser, utf8_filename);
1947 g_free (utf8_filename);
1950 #undef gtk_file_chooser_get_filenames
1953 gtk_file_chooser_get_filenames (GtkFileChooser *chooser)
1955 GSList *list = gtk_file_chooser_get_filenames_utf8 (chooser);
1956 GSList *rover = list;
1960 gchar *tem = (gchar *) rover->data;
1961 rover->data = g_locale_from_utf8 ((gchar *) rover->data, -1, NULL, NULL, NULL);
1963 rover = rover->next;
1969 #undef gtk_file_chooser_set_current_folder
1972 gtk_file_chooser_set_current_folder (GtkFileChooser *chooser,
1973 const gchar *filename)
1975 gchar *utf8_filename = g_locale_to_utf8 (filename, -1, NULL, NULL, NULL);
1976 gboolean retval = gtk_file_chooser_set_current_folder_utf8 (chooser, utf8_filename);
1978 g_free (utf8_filename);
1983 #undef gtk_file_chooser_get_current_folder
1986 gtk_file_chooser_get_current_folder (GtkFileChooser *chooser)
1988 gchar *utf8_folder = gtk_file_chooser_get_current_folder_utf8 (chooser);
1989 gchar *retval = g_locale_from_utf8 (utf8_folder, -1, NULL, NULL, NULL);
1991 g_free (utf8_folder);
1996 #undef gtk_file_chooser_get_preview_filename
1999 gtk_file_chooser_get_preview_filename (GtkFileChooser *chooser)
2001 char *utf8_filename = gtk_file_chooser_get_preview_filename_utf8 (chooser);
2002 char *retval = g_locale_from_utf8 (utf8_filename, -1, NULL, NULL, NULL);
2004 g_free (utf8_filename);
2009 #undef gtk_file_chooser_add_shortcut_folder
2012 gtk_file_chooser_add_shortcut_folder (GtkFileChooser *chooser,
2016 char *utf8_folder = g_locale_to_utf8 (folder, -1, NULL, NULL, NULL);
2018 gtk_file_chooser_add_shortcut_folder_utf8 (chooser, utf8_folder, error);
2020 g_free (utf8_folder);
2025 #undef gtk_file_chooser_remove_shortcut_folder
2028 gtk_file_chooser_remove_shortcut_folder (GtkFileChooser *chooser,
2032 char *utf8_folder = g_locale_to_utf8 (folder, -1, NULL, NULL, NULL);
2034 gtk_file_chooser_remove_shortcut_folder_utf8 (chooser, utf8_folder, error);
2036 g_free (utf8_folder);
2041 #undef gtk_file_chooser_list_shortcut_folders
2044 gtk_file_chooser_list_shortcut_folders (GtkFileChooser *chooser)
2046 GSList *list = gtk_file_chooser_list_shortcut_folders_utf8 (chooser);
2047 GSList *rover = list;
2051 gchar *tem = (gchar *) rover->data;
2052 rover->data = g_locale_from_utf8 ((gchar *) rover->data, -1, NULL, NULL, NULL);
2054 rover = rover->next;
2062 #define __GTK_FILE_CHOOSER_C__
2063 #include "gtkaliasdef.c"