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"
31 * SECTION:gtkfilechooser
32 * @Short_description: File chooser interface used by GtkFileChooserWidget and GtkFileChooserDialog
33 * @Title: GtkFileChooser
34 * @See_also: #GtkFileChooserDialog, #GtkFileChooserWidget, #GtkFileChooserButton
36 * #GtkFileChooser is an interface that can be implemented by file
37 * selection widgets. In GTK+, the main objects that implement this
38 * interface are #GtkFileChooserWidget, #GtkFileChooserDialog, and
39 * #GtkFileChooserButton. You do not need to write an object that
40 * implements the #GtkFileChooser interface unless you are trying to
41 * adapt an existing file selector to expose a standard programming
44 * #GtkFileChooser allows for shortcuts to various places in the filesystem.
45 * In the default implementation these are displayed in the left pane. It
46 * may be a bit confusing at first that these shortcuts come from various
47 * sources and in various flavours, so lets explain the terminology here:
50 * <term>Bookmarks</term>
52 * are created by the user, by dragging folders from the
53 * right pane to the left pane, or by using the "Add". Bookmarks
54 * can be renamed and deleted by the user.
58 * <term>Shortcuts</term>
60 * can be provided by the application or by the underlying filesystem
61 * abstraction (e.g. both the gnome-vfs and the Windows filesystems
62 * provide "Desktop" shortcuts). Shortcuts cannot be modified by the
67 * <term>Volumes</term>
69 * are provided by the underlying filesystem abstraction. They are
70 * the "roots" of the filesystem.
75 * <refsect2 id="gtkfilechooser-encodings">
76 * <title>File Names and Encodings</title>
77 * When the user is finished selecting files in a
78 * #GtkFileChooser, your program can get the selected names
79 * either as filenames or as URIs. For URIs, the normal escaping
80 * rules are applied if the URI contains non-ASCII characters.
81 * However, filenames are <emphasis>always</emphasis> returned in
82 * the character set specified by the
83 * <envar>G_FILENAME_ENCODING</envar> environment variable.
84 * Please see the Glib documentation for more details about this
87 * This means that while you can pass the result of
88 * gtk_file_chooser_get_filename() to
89 * <function>open(2)</function> or
90 * <function>fopen(3)</function>, you may not be able to
91 * directly set it as the text of a #GtkLabel widget unless you
92 * convert it first to UTF-8, which all GTK+ widgets expect.
93 * You should use g_filename_to_utf8() to convert filenames
94 * into strings that can be passed to GTK+ widgets.
97 * <refsect2 id="gtkfilechooser-preview">
98 * <title>Adding a Preview Widget</title>
100 * You can add a custom preview widget to a file chooser and then
101 * get notification about when the preview needs to be updated.
102 * To install a preview widget, use
103 * gtk_file_chooser_set_preview_widget(). Then, connect to the
104 * #GtkFileChooser::update-preview signal to get notified when
105 * you need to update the contents of the preview.
108 * Your callback should use
109 * gtk_file_chooser_get_preview_filename() to see what needs
110 * previewing. Once you have generated the preview for the
111 * corresponding file, you must call
112 * gtk_file_chooser_set_preview_widget_active() with a boolean
113 * flag that indicates whether your callback could successfully
114 * generate a preview.
116 * <example id="example-gtkfilechooser-preview">
117 * <title>Sample Usage</title>
124 * preview = gtk_image_new (<!-- -->);
126 * gtk_file_chooser_set_preview_widget (my_file_chooser, preview);
127 * g_signal_connect (my_file_chooser, "update-preview",
128 * G_CALLBACK (update_preview_cb), preview);
132 * update_preview_cb (GtkFileChooser *file_chooser, gpointer data)
134 * GtkWidget *preview;
137 * gboolean have_preview;
139 * preview = GTK_WIDGET (data);
140 * filename = gtk_file_chooser_get_preview_filename (file_chooser);
142 * pixbuf = gdk_pixbuf_new_from_file_at_size (filename, 128, 128, NULL);
143 * have_preview = (pixbuf != NULL);
146 * gtk_image_set_from_pixbuf (GTK_IMAGE (preview), pixbuf);
148 * g_object_unref (pixbuf);
150 * gtk_file_chooser_set_preview_widget_active (file_chooser, have_preview);
155 * <refsect2 id="gtkfilechooser-extra">
156 * <title>Adding Extra Widgets</title>
158 * You can add extra widgets to a file chooser to provide options
159 * that are not present in the default design. For example, you
160 * can add a toggle button to give the user the option to open a
161 * file in read-only mode. You can use
162 * gtk_file_chooser_set_extra_widget() to insert additional
163 * widgets in a file chooser.
165 * <example id="example-gtkfilechooser-extra">
166 * <title>Sample Usage</title>
173 * toggle = gtk_check_button_new_with_label ("Open file read-only");
174 * gtk_widget_show (toggle);
175 * gtk_file_chooser_set_extra_widget (my_file_chooser, toggle);
180 * If you want to set more than one extra widget in the file
181 * chooser, you can a container such as a #GtkVBox or a #GtkTable
182 * and include your widgets in it. Then, set the container as
183 * the whole extra widget.
186 * <refsect2 id="gtkfilechooser-key-bindings">
187 * <title>Key Bindings</title>
189 * Internally, GTK+ implements a file chooser's graphical user
190 * interface with the private
191 * <classname>GtkFileChooserDefaultClass</classname>. This
192 * widget has several <link linkend="gtk-Bindings">key
193 * bindings</link> and their associated signals. This section
194 * describes the available key binding signals.
196 * <example id="gtkfilechooser-key-binding-example">
197 * <title>GtkFileChooser key binding example</title>
199 * The default keys that activate the key-binding signals in
200 * <classname>GtkFileChooserDefaultClass</classname> are as
207 * <entry>Signal name</entry>
208 * <entry>Default key combinations</entry>
211 * <entry>location-popup</entry>
213 * <keycombo><keycap>Control</keycap><keycap>L</keycap></keycombo> (empty path);
214 * <keycap>/</keycap> (path of "/")
216 * Both the individual <keycap>/</keycap> key and the
217 * numeric keypad's "divide" key are supported.
219 * <keycap>~</keycap> (path of "~")
223 * <entry>up-folder</entry>
225 * <keycombo><keycap>Alt</keycap><keycap>Up</keycap></keycombo>
227 * Both the individual Up key and the numeric
228 * keypad's Up key are supported.
231 * <keycap>Backspace</keycap>
235 * <entry>down-folder</entry>
236 * <entry><keycombo><keycap>Alt</keycap><keycap>Down</keycap></keycombo></entry>
239 * <entry>home-folder</entry>
240 * <entry><keycombo><keycap>Alt</keycap><keycap>Home</keycap></keycombo></entry>
243 * <entry>desktop-folder</entry>
244 * <entry><keycombo><keycap>Alt</keycap><keycap>D</keycap></keycombo></entry>
247 * <entry>quick-bookmark</entry>
248 * <entry><keycombo><keycap>Alt</keycap><keycap>1</keycap></keycombo> through <keycombo><keycap>Alt</keycap><keycap>0</keycap></keycombo></entry>
254 * You can change these defaults to something else. For
255 * example, to add a <keycap>Shift</keycap> modifier to a few
256 * of the default bindings, you can include the following
257 * fragment in your <filename>.gtkrc-3.0</filename> file:
260 * binding "my-own-gtkfilechooser-bindings" {
261 * bind "<Alt><Shift>Up" {
264 * bind "<Alt><Shift>Down" {
267 * bind "<Alt><Shift>Home" {
272 * class "GtkFileChooserDefault" binding "my-own-gtkfilechooser-bindings"
275 * <refsect3 id="GtkFileChooserDefault-location-popup">
276 * <title>The "GtkFileChooserDefault::location-popup" signal</title>
278 * void user_function (GtkFileChooserDefault *chooser,
280 * <link linkend="gpointer">gpointer</link> user_data);
283 * This is used to make the file chooser show a "Location"
284 * dialog which the user can use to manually type the name of
285 * the file he wishes to select. The
286 * <parameter>path</parameter> argument is a string that gets
287 * put in the text entry for the file name. By default this is bound to
288 * <keycombo><keycap>Control</keycap><keycap>L</keycap></keycombo>
289 * with a <parameter>path</parameter> string of "" (the empty
290 * string). It is also bound to <keycap>/</keycap> with a
291 * <parameter>path</parameter> string of "<literal>/</literal>"
292 * (a slash): this lets you type <keycap>/</keycap> and
293 * immediately type a path name. On Unix systems, this is bound to
294 * <keycap>~</keycap> (tilde) with a <parameter>path</parameter> string
295 * of "~" itself for access to home directories.
297 * <variablelist role="params">
299 * <term><parameter>chooser</parameter> :</term>
302 * the object which received the signal.
307 * <term><parameter>path</parameter> :</term>
310 * default contents for the text entry for the file name
315 * <term><parameter>user_data</parameter> :</term>
318 * user data set when the signal handler was connected.
324 * You can create your own bindings for the
325 * #GtkFileChooserDefault::location-popup signal with custom
326 * <parameter>path</parameter> strings, and have a crude form
327 * of easily-to-type bookmarks. For example, say you access
328 * the path <filename>/home/username/misc</filename> very
329 * frequently. You could then create an <keycombo>
330 * <keycap>Alt</keycap> <keycap>M</keycap> </keycombo>
331 * shortcut by including the following in your
332 * <filename>.gtkrc-3.0</filename>:
334 * binding "misc-shortcut" {
335 * bind "<Alt>M" {
336 * "location-popup" ("/home/username/misc")
340 * class "GtkFileChooserDefault" binding "misc-shortcut"
344 * <refsect3 id="GtkFileChooserDefault-up-folder">
345 * <title>The "GtkFileChooserDefault::up-folder" signal</title>
347 * void user_function (GtkFileChooserDefault *chooser,
348 * <link linkend="gpointer">gpointer</link> user_data);
351 * This is used to make the file chooser go to the parent of
352 * the current folder in the file hierarchy. By default this
353 * is bound to <keycap>Backspace</keycap> and
354 * <keycombo><keycap>Alt</keycap><keycap>Up</keycap></keycombo>
355 * (the Up key in the numeric keypad also works).
357 * <variablelist role="params">
359 * <term><parameter>chooser</parameter> :</term>
362 * the object which received the signal.
367 * <term><parameter>user_data</parameter> :</term>
370 * user data set when the signal handler was connected.
376 * <refsect3 id="GtkFileChooserDefault-down-folder">
377 * <title>The "GtkFileChooserDefault::down-folder" signal</title>
379 * void user_function (GtkFileChooserDefault *chooser,
380 * <link linkend="gpointer">gpointer</link> user_data);
383 * This is used to make the file chooser go to a child of the
384 * current folder in the file hierarchy. The subfolder that
385 * will be used is displayed in the path bar widget of the file
386 * chooser. For example, if the path bar is showing
387 * "/foo/<emphasis>bar/</emphasis>baz", then this will cause
388 * the file chooser to switch to the "baz" subfolder. By
389 * default this is bound to
390 * <keycombo><keycap>Alt</keycap><keycap>Down</keycap></keycombo>
391 * (the Down key in the numeric keypad also works).
393 * <variablelist role="params">
395 * <term><parameter>chooser</parameter> :</term>
398 * the object which received the signal.
403 * <term><parameter>user_data</parameter> :</term>
406 * user data set when the signal handler was connected.
412 * <refsect3 id="GtkFileChooserDefault-home-folder">
413 * <title>The "GtkFileChooserDefault::home-folder" signal</title>
415 * void user_function (GtkFileChooserDefault *chooser,
416 * <link linkend="gpointer">gpointer</link> user_data);
419 * This is used to make the file chooser show the user's home
420 * folder in the file list. By default this is bound to
421 * <keycombo><keycap>Alt</keycap><keycap>Home</keycap></keycombo>
422 * (the Home key in the numeric keypad also works).
424 * <variablelist role="params">
426 * <term><parameter>chooser</parameter> :</term>
429 * the object which received the signal.
434 * <term><parameter>user_data</parameter> :</term>
437 * user data set when the signal handler was connected.
443 * <refsect3 id="GtkFileChooserDefault-desktop-folder">
444 * <title>The "GtkFileChooserDefault::desktop-folder" signal</title>
446 * void user_function (GtkFileChooserDefault *chooser,
447 * <link linkend="gpointer">gpointer</link> user_data);
450 * This is used to make the file chooser show the user's Desktop
451 * folder in the file list. By default this is bound to
452 * <keycombo><keycap>Alt</keycap><keycap>D</keycap></keycombo>.
454 * <variablelist role="params">
456 * <term><parameter>chooser</parameter> :</term>
459 * the object which received the signal.
464 * <term><parameter>user_data</parameter> :</term>
467 * user data set when the signal handler was connected.
473 * <refsect3 id="GtkFileChooserDefault-quick-bookmark">
474 * <title>The "GtkFileChooserDefault::quick-bookmark" signal</title>
476 * void user_function (GtkFileChooserDefault *chooser,
477 * gint bookmark_index,
478 * <link linkend="gpointer">gpointer</link> user_data);
481 * This is used to make the file chooser switch to the bookmark
482 * specified in the <parameter>bookmark_index</parameter> parameter.
483 * For example, if you have three bookmarks, you can pass 0, 1, 2 to
484 * this signal to switch to each of them, respectively. By default this is bound to
485 * <keycombo><keycap>Alt</keycap><keycap>1</keycap></keycombo>,
486 * <keycombo><keycap>Alt</keycap><keycap>2</keycap></keycombo>,
488 * <keycombo><keycap>Alt</keycap><keycap>0</keycap></keycombo>. Note
489 * that in the default binding,
490 * that <keycombo><keycap>Alt</keycap><keycap>1</keycap></keycombo> is
491 * actually defined to switch to the bookmark at index 0, and so on
493 * <keycombo><keycap>Alt</keycap><keycap>0</keycap></keycombo> is
494 * defined to switch to the bookmark at index 10.
496 * <variablelist role="params">
498 * <term><parameter>chooser</parameter> :</term>
501 * the object which received the signal.
506 * <term><parameter>bookmark_indes</parameter> :</term>
509 * index of the bookmark to switch to; the indices start at 0.
514 * <term><parameter>user_data</parameter> :</term>
517 * user data set when the signal handler was connected.
527 typedef GtkFileChooserIface GtkFileChooserInterface;
528 G_DEFINE_INTERFACE (GtkFileChooser, gtk_file_chooser, GTK_TYPE_WIDGET);
531 confirm_overwrite_accumulator (GSignalInvocationHint *ihint,
533 const GValue *handler_return,
536 gboolean continue_emission;
537 GtkFileChooserConfirmation conf;
539 conf = g_value_get_enum (handler_return);
540 g_value_set_enum (return_accu, conf);
541 continue_emission = (conf == GTK_FILE_CHOOSER_CONFIRMATION_CONFIRM);
543 return continue_emission;
547 gtk_file_chooser_default_init (GtkFileChooserInterface *iface)
549 GType iface_type = G_TYPE_FROM_INTERFACE (iface);
552 * GtkFileChooser::current-folder-changed
553 * @chooser: the object which received the signal.
555 * This signal is emitted when the current folder in a #GtkFileChooser
556 * changes. This can happen due to the user performing some action that
557 * changes folders, such as selecting a bookmark or visiting a folder on the
558 * file list. It can also happen as a result of calling a function to
559 * explicitly change the current folder in a file chooser.
561 * Normally you do not need to connect to this signal, unless you need to keep
562 * track of which folder a file chooser is showing.
564 * See also: gtk_file_chooser_set_current_folder(),
565 * gtk_file_chooser_get_current_folder(),
566 * gtk_file_chooser_set_current_folder_uri(),
567 * gtk_file_chooser_get_current_folder_uri().
569 g_signal_new (I_("current-folder-changed"),
572 G_STRUCT_OFFSET (GtkFileChooserIface, current_folder_changed),
574 g_cclosure_marshal_VOID__VOID,
578 * GtkFileChooser::selection-changed
579 * @chooser: the object which received the signal.
581 * This signal is emitted when there is a change in the set of selected files
582 * in a #GtkFileChooser. This can happen when the user modifies the selection
583 * with the mouse or the keyboard, or when explicitly calling functions to
584 * change the selection.
586 * Normally you do not need to connect to this signal, as it is easier to wait
587 * for the file chooser to finish running, and then to get the list of
588 * selected files using the functions mentioned below.
590 * See also: gtk_file_chooser_select_filename(),
591 * gtk_file_chooser_unselect_filename(), gtk_file_chooser_get_filename(),
592 * gtk_file_chooser_get_filenames(), gtk_file_chooser_select_uri(),
593 * gtk_file_chooser_unselect_uri(), gtk_file_chooser_get_uri(),
594 * gtk_file_chooser_get_uris().
596 g_signal_new (I_("selection-changed"),
599 G_STRUCT_OFFSET (GtkFileChooserIface, selection_changed),
601 g_cclosure_marshal_VOID__VOID,
605 * GtkFileChooser::update-preview
606 * @chooser: the object which received the signal.
608 * This signal is emitted when the preview in a file chooser should be
609 * regenerated. For example, this can happen when the currently selected file
610 * changes. You should use this signal if you want your file chooser to have
613 * Once you have installed a preview widget with
614 * gtk_file_chooser_set_preview_widget(), you should update it when this
615 * signal is emitted. You can use the functions
616 * gtk_file_chooser_get_preview_filename() or
617 * gtk_file_chooser_get_preview_uri() to get the name of the file to preview.
618 * Your widget may not be able to preview all kinds of files; your callback
619 * must call gtk_file_chooser_set_preview_widget_active() to inform the file
620 * chooser about whether the preview was generated successfully or not.
622 * Please see the example code in <xref linkend="gtkfilechooser-preview"/>.
624 * See also: gtk_file_chooser_set_preview_widget(),
625 * gtk_file_chooser_set_preview_widget_active(),
626 * gtk_file_chooser_set_use_preview_label(),
627 * gtk_file_chooser_get_preview_filename(),
628 * gtk_file_chooser_get_preview_uri().
630 g_signal_new (I_("update-preview"),
633 G_STRUCT_OFFSET (GtkFileChooserIface, update_preview),
635 g_cclosure_marshal_VOID__VOID,
639 * GtkFileChooser::file-activated
640 * @chooser: the object which received the signal.
642 * This signal is emitted when the user "activates" a file in the file
643 * chooser. This can happen by double-clicking on a file in the file list, or
644 * by pressing <keycap>Enter</keycap>.
646 * Normally you do not need to connect to this signal. It is used internally
647 * by #GtkFileChooserDialog to know when to activate the default button in the
650 * See also: gtk_file_chooser_get_filename(),
651 * gtk_file_chooser_get_filenames(), gtk_file_chooser_get_uri(),
652 * gtk_file_chooser_get_uris().
654 g_signal_new (I_("file-activated"),
657 G_STRUCT_OFFSET (GtkFileChooserIface, file_activated),
659 g_cclosure_marshal_VOID__VOID,
663 * GtkFileChooser::confirm-overwrite:
664 * @chooser: the object which received the signal.
666 * This signal gets emitted whenever it is appropriate to present a
667 * confirmation dialog when the user has selected a file name that
668 * already exists. The signal only gets emitted when the file
669 * chooser is in %GTK_FILE_CHOOSER_ACTION_SAVE mode.
671 * Most applications just need to turn on the
672 * #GtkFileChooser:do-overwrite-confirmation property (or call the
673 * gtk_file_chooser_set_do_overwrite_confirmation() function), and
674 * they will automatically get a stock confirmation dialog.
675 * Applications which need to customize this behavior should do
676 * that, and also connect to the #GtkFileChooser::confirm-overwrite
679 * A signal handler for this signal must return a
680 * #GtkFileChooserConfirmation value, which indicates the action to
681 * take. If the handler determines that the user wants to select a
682 * different filename, it should return
683 * %GTK_FILE_CHOOSER_CONFIRMATION_SELECT_AGAIN. If it determines
684 * that the user is satisfied with his choice of file name, it
685 * should return %GTK_FILE_CHOOSER_CONFIRMATION_ACCEPT_FILENAME.
686 * On the other hand, if it determines that the stock confirmation
687 * dialog should be used, it should return
688 * %GTK_FILE_CHOOSER_CONFIRMATION_CONFIRM. The following example
690 * <example id="gtkfilechooser-confirmation">
691 * <title>Custom confirmation</title>
693 * static GtkFileChooserConfirmation
694 * confirm_overwrite_callback (GtkFileChooser *chooser, gpointer data)
698 * uri = gtk_file_chooser_get_uri (chooser);
700 * if (is_uri_read_only (uri))
702 * if (user_wants_to_replace_read_only_file (uri))
703 * return GTK_FILE_CHOOSER_CONFIRMATION_ACCEPT_FILENAME;
705 * return GTK_FILE_CHOOSER_CONFIRMATION_SELECT_AGAIN;
707 * return GTK_FILE_CHOOSER_CONFIRMATION_CONFIRM; // fall back to the default dialog
712 * chooser = gtk_file_chooser_dialog_new (...);
714 * gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), TRUE);
715 * g_signal_connect (chooser, "confirm-overwrite",
716 * G_CALLBACK (confirm_overwrite_callback), NULL);
718 * if (gtk_dialog_run (chooser) == GTK_RESPONSE_ACCEPT)
719 * save_to_file (gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (chooser));
721 * gtk_widget_destroy (chooser);
725 * Returns: a #GtkFileChooserConfirmation value that indicates which
726 * action to take after emitting the signal.
730 g_signal_new (I_("confirm-overwrite"),
733 G_STRUCT_OFFSET (GtkFileChooserIface, confirm_overwrite),
734 confirm_overwrite_accumulator, NULL,
735 _gtk_marshal_ENUM__VOID,
736 GTK_TYPE_FILE_CHOOSER_CONFIRMATION, 0);
738 g_object_interface_install_property (iface,
739 g_param_spec_enum ("action",
741 P_("The type of operation that the file selector is performing"),
742 GTK_TYPE_FILE_CHOOSER_ACTION,
743 GTK_FILE_CHOOSER_ACTION_OPEN,
744 GTK_PARAM_READWRITE));
745 g_object_interface_install_property (iface,
746 g_param_spec_object ("filter",
748 P_("The current filter for selecting which files are displayed"),
749 GTK_TYPE_FILE_FILTER,
750 GTK_PARAM_READWRITE));
751 g_object_interface_install_property (iface,
752 g_param_spec_boolean ("local-only",
754 P_("Whether the selected file(s) should be limited to local file: URLs"),
756 GTK_PARAM_READWRITE));
757 g_object_interface_install_property (iface,
758 g_param_spec_object ("preview-widget",
759 P_("Preview widget"),
760 P_("Application supplied widget for custom previews."),
762 GTK_PARAM_READWRITE));
763 g_object_interface_install_property (iface,
764 g_param_spec_boolean ("preview-widget-active",
765 P_("Preview Widget Active"),
766 P_("Whether the application supplied widget for custom previews should be shown."),
768 GTK_PARAM_READWRITE));
769 g_object_interface_install_property (iface,
770 g_param_spec_boolean ("use-preview-label",
771 P_("Use Preview Label"),
772 P_("Whether to display a stock label with the name of the previewed file."),
774 GTK_PARAM_READWRITE));
775 g_object_interface_install_property (iface,
776 g_param_spec_object ("extra-widget",
778 P_("Application supplied widget for extra options."),
780 GTK_PARAM_READWRITE));
781 g_object_interface_install_property (iface,
782 g_param_spec_boolean ("select-multiple",
783 P_("Select Multiple"),
784 P_("Whether to allow multiple files to be selected"),
786 GTK_PARAM_READWRITE));
788 g_object_interface_install_property (iface,
789 g_param_spec_boolean ("show-hidden",
791 P_("Whether the hidden files and folders should be displayed"),
793 GTK_PARAM_READWRITE));
796 * GtkFileChooser:do-overwrite-confirmation:
798 * Whether a file chooser in %GTK_FILE_CHOOSER_ACTION_SAVE mode
799 * will present an overwrite confirmation dialog if the user
800 * selects a file name that already exists.
804 g_object_interface_install_property (iface,
805 g_param_spec_boolean ("do-overwrite-confirmation",
806 P_("Do overwrite confirmation"),
807 P_("Whether a file chooser in save mode "
808 "will present an overwrite confirmation dialog "
811 GTK_PARAM_READWRITE));
814 * GtkFileChooser:create-folders:
816 * Whether a file chooser not in %GTK_FILE_CHOOSER_ACTION_OPEN mode
817 * will offer the user to create new folders.
821 g_object_interface_install_property (iface,
822 g_param_spec_boolean ("create-folders",
823 P_("Allow folder creation"),
824 P_("Whether a file chooser not in open mode "
825 "will offer the user to create new folders."),
827 GTK_PARAM_READWRITE));
831 * gtk_file_chooser_error_quark:
833 * Registers an error quark for #GtkFileChooser if necessary.
835 * Return value: The error quark used for #GtkFileChooser errors.
840 gtk_file_chooser_error_quark (void)
842 return g_quark_from_static_string ("gtk-file-chooser-error-quark");
846 * gtk_file_chooser_set_action:
847 * @chooser: a #GtkFileChooser
848 * @action: the action that the file selector is performing
850 * Sets the type of operation that the chooser is performing; the
851 * user interface is adapted to suit the selected action. For example,
852 * an option to create a new folder might be shown if the action is
853 * %GTK_FILE_CHOOSER_ACTION_SAVE but not if the action is
854 * %GTK_FILE_CHOOSER_ACTION_OPEN.
859 gtk_file_chooser_set_action (GtkFileChooser *chooser,
860 GtkFileChooserAction action)
862 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
864 g_object_set (chooser, "action", action, NULL);
868 * gtk_file_chooser_get_action:
869 * @chooser: a #GtkFileChooser
871 * Gets the type of operation that the file chooser is performing; see
872 * gtk_file_chooser_set_action().
874 * Return value: the action that the file selector is performing
879 gtk_file_chooser_get_action (GtkFileChooser *chooser)
881 GtkFileChooserAction action;
883 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
885 g_object_get (chooser, "action", &action, NULL);
891 * gtk_file_chooser_set_local_only:
892 * @chooser: a #GtkFileChooser
893 * @local_only: %TRUE if only local files can be selected
895 * Sets whether only local files can be selected in the
896 * file selector. If @local_only is %TRUE (the default),
897 * then the selected file are files are guaranteed to be
898 * accessible through the operating systems native file
899 * file system and therefore the application only
900 * needs to worry about the filename functions in
901 * #GtkFileChooser, like gtk_file_chooser_get_filename(),
902 * rather than the URI functions like
903 * gtk_file_chooser_get_uri(),
908 gtk_file_chooser_set_local_only (GtkFileChooser *chooser,
911 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
913 g_object_set (chooser, "local-only", local_only, NULL);
917 * gtk_file_chooser_get_local_only:
918 * @chooser: a #GtkFileChooser
920 * Gets whether only local files can be selected in the
921 * file selector. See gtk_file_chooser_set_local_only()
923 * Return value: %TRUE if only local files can be selected.
928 gtk_file_chooser_get_local_only (GtkFileChooser *chooser)
932 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
934 g_object_get (chooser, "local-only", &local_only, NULL);
940 * gtk_file_chooser_set_select_multiple:
941 * @chooser: a #GtkFileChooser
942 * @select_multiple: %TRUE if multiple files can be selected.
944 * Sets whether multiple files can be selected in the file selector. This is
945 * only relevant if the action is set to be %GTK_FILE_CHOOSER_ACTION_OPEN or
946 * %GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER.
951 gtk_file_chooser_set_select_multiple (GtkFileChooser *chooser,
952 gboolean select_multiple)
954 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
956 g_object_set (chooser, "select-multiple", select_multiple, NULL);
960 * gtk_file_chooser_get_select_multiple:
961 * @chooser: a #GtkFileChooser
963 * Gets whether multiple files can be selected in the file
964 * selector. See gtk_file_chooser_set_select_multiple().
966 * Return value: %TRUE if multiple files can be selected.
971 gtk_file_chooser_get_select_multiple (GtkFileChooser *chooser)
973 gboolean select_multiple;
975 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
977 g_object_get (chooser, "select-multiple", &select_multiple, NULL);
979 return select_multiple;
983 * gtk_file_chooser_set_create_folders:
984 * @chooser: a #GtkFileChooser
985 * @create_folders: %TRUE if the New Folder button should be displayed
987 * Sets whether file choser will offer to create new folders.
988 * This is only relevant if the action is not set to be
989 * %GTK_FILE_CHOOSER_ACTION_OPEN.
994 gtk_file_chooser_set_create_folders (GtkFileChooser *chooser,
995 gboolean create_folders)
997 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
999 g_object_set (chooser, "create-folders", create_folders, NULL);
1003 * gtk_file_chooser_get_create_folders:
1004 * @chooser: a #GtkFileChooser
1006 * Gets whether file choser will offer to create new folders.
1007 * See gtk_file_chooser_set_create_folders().
1009 * Return value: %TRUE if the New Folder button should be displayed.
1014 gtk_file_chooser_get_create_folders (GtkFileChooser *chooser)
1016 gboolean create_folders;
1018 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1020 g_object_get (chooser, "create-folders", &create_folders, NULL);
1022 return create_folders;
1026 * gtk_file_chooser_get_filename:
1027 * @chooser: a #GtkFileChooser
1029 * Gets the filename for the currently selected file in
1030 * the file selector. If multiple files are selected,
1031 * one of the filenames will be returned at random.
1033 * If the file chooser is in folder mode, this function returns the selected
1036 * Return value: (type filename): The currently selected filename, or %NULL
1037 * if no file is selected, or the selected file can't
1038 * be represented with a local filename. Free with g_free().
1043 gtk_file_chooser_get_filename (GtkFileChooser *chooser)
1046 gchar *result = NULL;
1048 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1050 file = gtk_file_chooser_get_file (chooser);
1054 result = g_file_get_path (file);
1055 g_object_unref (file);
1062 * gtk_file_chooser_set_filename:
1063 * @chooser: a #GtkFileChooser
1064 * @filename: (type filename): the filename to set as current
1066 * Sets @filename as the current filename for the file chooser, by changing
1067 * to the file's parent folder and actually selecting the file in list. If
1068 * the @chooser is in %GTK_FILE_CHOOSER_ACTION_SAVE mode, the file's base name
1069 * will also appear in the dialog's file name entry.
1071 * If the file name isn't in the current folder of @chooser, then the current
1072 * folder of @chooser will be changed to the folder containing @filename. This
1073 * is equivalent to a sequence of gtk_file_chooser_unselect_all() followed by
1074 * gtk_file_chooser_select_filename().
1076 * Note that the file must exist, or nothing will be done except
1077 * for the directory change.
1079 * If you are implementing a <guimenuitem>File/Save As...</guimenuitem> dialog,
1080 * you should use this function if you already have a file name to which the
1081 * user may save; for example, when the user opens an existing file and then
1082 * does <guimenuitem>File/Save As...</guimenuitem> on it. If you don't have
1083 * a file name already — for example, if the user just created a new
1084 * file and is saving it for the first time, do not call this function.
1085 * Instead, use something similar to this:
1087 * if (document_is_new)
1089 * /* the user just created a new document */
1090 * gtk_file_chooser_set_current_folder (chooser, default_folder_for_saving);
1091 * gtk_file_chooser_set_current_name (chooser, "Untitled document");
1095 * /* the user edited an existing document */
1096 * gtk_file_chooser_set_filename (chooser, existing_filename);
1100 * Return value: %TRUE if both the folder could be changed and the file was
1101 * selected successfully, %FALSE otherwise.
1106 gtk_file_chooser_set_filename (GtkFileChooser *chooser,
1107 const gchar *filename)
1109 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1111 gtk_file_chooser_unselect_all (chooser);
1112 return gtk_file_chooser_select_filename (chooser, filename);
1116 * gtk_file_chooser_select_filename:
1117 * @chooser: a #GtkFileChooser
1118 * @filename: (type filename): the filename to select
1120 * Selects a filename. If the file name isn't in the current
1121 * folder of @chooser, then the current folder of @chooser will
1122 * be changed to the folder containing @filename.
1124 * Return value: %TRUE if both the folder could be changed and the file was
1125 * selected successfully, %FALSE otherwise.
1130 gtk_file_chooser_select_filename (GtkFileChooser *chooser,
1131 const gchar *filename)
1136 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1137 g_return_val_if_fail (filename != NULL, FALSE);
1139 file = g_file_new_for_path (filename);
1140 result = gtk_file_chooser_select_file (chooser, file, NULL);
1141 g_object_unref (file);
1147 * gtk_file_chooser_unselect_filename:
1148 * @chooser: a #GtkFileChooser
1149 * @filename: (type filename): the filename to unselect
1151 * Unselects a currently selected filename. If the filename
1152 * is not in the current directory, does not exist, or
1153 * is otherwise not currently selected, does nothing.
1158 gtk_file_chooser_unselect_filename (GtkFileChooser *chooser,
1159 const char *filename)
1163 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1164 g_return_if_fail (filename != NULL);
1166 file = g_file_new_for_path (filename);
1167 gtk_file_chooser_unselect_file (chooser, file);
1168 g_object_unref (file);
1171 /* Converts a list of GFile* to a list of strings using the specified function */
1173 files_to_strings (GSList *files,
1174 gchar * (*convert_func) (GFile *file))
1180 for (; files; files = files->next)
1186 string = (* convert_func) (file);
1189 strings = g_slist_prepend (strings, string);
1192 return g_slist_reverse (strings);
1196 * gtk_file_chooser_get_filenames:
1197 * @chooser: a #GtkFileChooser
1199 * Lists all the selected files and subfolders in the current folder of
1200 * @chooser. The returned names are full absolute paths. If files in the current
1201 * folder cannot be represented as local filenames they will be ignored. (See
1202 * gtk_file_chooser_get_uris())
1204 * Return value: (element-type filename) (transfer full): a #GSList
1205 * containing the filenames of all selected files and subfolders in
1206 * the current folder. Free the returned list with g_slist_free(),
1207 * and the filenames with g_free().
1212 gtk_file_chooser_get_filenames (GtkFileChooser *chooser)
1214 GSList *files, *result;
1216 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1218 files = gtk_file_chooser_get_files (chooser);
1220 result = files_to_strings (files, g_file_get_path);
1221 g_slist_foreach (files, (GFunc) g_object_unref, NULL);
1222 g_slist_free (files);
1228 * gtk_file_chooser_set_current_folder:
1229 * @chooser: a #GtkFileChooser
1230 * @filename: (type filename): the full path of the new current folder
1232 * Sets the current folder for @chooser from a local filename.
1233 * The user will be shown the full contents of the current folder,
1234 * plus user interface elements for navigating to other folders.
1236 * Return value: %TRUE if the folder could be changed successfully, %FALSE
1242 gtk_file_chooser_set_current_folder (GtkFileChooser *chooser,
1243 const gchar *filename)
1248 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1249 g_return_val_if_fail (filename != NULL, FALSE);
1251 file = g_file_new_for_path (filename);
1252 result = gtk_file_chooser_set_current_folder_file (chooser, file, NULL);
1253 g_object_unref (file);
1259 * gtk_file_chooser_get_current_folder:
1260 * @chooser: a #GtkFileChooser
1262 * Gets the current folder of @chooser as a local filename.
1263 * See gtk_file_chooser_set_current_folder().
1265 * Note that this is the folder that the file chooser is currently displaying
1266 * (e.g. "/home/username/Documents"), which is <emphasis>not the same</emphasis>
1267 * as the currently-selected folder if the chooser is in
1268 * %GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER mode
1269 * (e.g. "/home/username/Documents/selected-folder/". To get the
1270 * currently-selected folder in that mode, use gtk_file_chooser_get_uri() as the
1271 * usual way to get the selection.
1273 * Return value: (type filename): the full path of the current folder,
1274 * or %NULL if the current path cannot be represented as a local
1275 * filename. Free with g_free(). This function will also return
1276 * %NULL if the file chooser was unable to load the last folder that
1277 * was requested from it; for example, as would be for calling
1278 * gtk_file_chooser_set_current_folder() on a nonexistent folder.
1283 gtk_file_chooser_get_current_folder (GtkFileChooser *chooser)
1288 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1290 file = gtk_file_chooser_get_current_folder_file (chooser);
1294 filename = g_file_get_path (file);
1295 g_object_unref (file);
1301 * gtk_file_chooser_set_current_name:
1302 * @chooser: a #GtkFileChooser
1303 * @name: (type filename): the filename to use, as a UTF-8 string
1305 * Sets the current name in the file selector, as if entered
1306 * by the user. Note that the name passed in here is a UTF-8
1307 * string rather than a filename. This function is meant for
1308 * such uses as a suggested name in a "Save As..." dialog.
1310 * If you want to preselect a particular existing file, you should use
1311 * gtk_file_chooser_set_filename() or gtk_file_chooser_set_uri() instead.
1312 * Please see the documentation for those functions for an example of using
1313 * gtk_file_chooser_set_current_name() as well.
1318 gtk_file_chooser_set_current_name (GtkFileChooser *chooser,
1321 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1322 g_return_if_fail (name != NULL);
1324 GTK_FILE_CHOOSER_GET_IFACE (chooser)->set_current_name (chooser, name);
1328 * gtk_file_chooser_get_uri:
1329 * @chooser: a #GtkFileChooser
1331 * Gets the URI for the currently selected file in
1332 * the file selector. If multiple files are selected,
1333 * one of the filenames will be returned at random.
1335 * If the file chooser is in folder mode, this function returns the selected
1338 * Return value: The currently selected URI, or %NULL
1339 * if no file is selected. Free with g_free()
1344 gtk_file_chooser_get_uri (GtkFileChooser *chooser)
1347 gchar *result = NULL;
1349 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1351 file = gtk_file_chooser_get_file (chooser);
1354 result = g_file_get_uri (file);
1355 g_object_unref (file);
1362 * gtk_file_chooser_set_uri:
1363 * @chooser: a #GtkFileChooser
1364 * @uri: the URI to set as current
1366 * Sets the file referred to by @uri as the current file for the file chooser,
1367 * by changing to the URI's parent folder and actually selecting the URI in the
1368 * list. If the @chooser is %GTK_FILE_CHOOSER_ACTION_SAVE mode, the URI's base
1369 * name will also appear in the dialog's file name entry.
1371 * If the URI isn't in the current folder of @chooser, then the current folder
1372 * of @chooser will be changed to the folder containing @uri. This is equivalent
1373 * to a sequence of gtk_file_chooser_unselect_all() followed by
1374 * gtk_file_chooser_select_uri().
1376 * Note that the URI must exist, or nothing will be done except for the
1378 * If you are implementing a <guimenuitem>File/Save As...</guimenuitem> dialog,
1379 * you should use this function if you already have a file name to which the
1380 * user may save; for example, when the user opens an existing file and then
1381 * does <guimenuitem>File/Save As...</guimenuitem> on it. If you don't have
1382 * a file name already — for example, if the user just created a new
1383 * file and is saving it for the first time, do not call this function.
1384 * Instead, use something similar to this:
1386 * if (document_is_new)
1388 * /* the user just created a new document */
1389 * gtk_file_chooser_set_current_folder_uri (chooser, default_folder_for_saving);
1390 * gtk_file_chooser_set_current_name (chooser, "Untitled document");
1394 * /* the user edited an existing document */
1395 * gtk_file_chooser_set_uri (chooser, existing_uri);
1399 * Return value: %TRUE if both the folder could be changed and the URI was
1400 * selected successfully, %FALSE otherwise.
1405 gtk_file_chooser_set_uri (GtkFileChooser *chooser,
1408 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1410 gtk_file_chooser_unselect_all (chooser);
1411 return gtk_file_chooser_select_uri (chooser, uri);
1415 * gtk_file_chooser_select_uri:
1416 * @chooser: a #GtkFileChooser
1417 * @uri: the URI to select
1419 * Selects the file to by @uri. If the URI doesn't refer to a
1420 * file in the current folder of @chooser, then the current folder of
1421 * @chooser will be changed to the folder containing @filename.
1423 * Return value: %TRUE if both the folder could be changed and the URI was
1424 * selected successfully, %FALSE otherwise.
1429 gtk_file_chooser_select_uri (GtkFileChooser *chooser,
1435 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1436 g_return_val_if_fail (uri != NULL, FALSE);
1438 file = g_file_new_for_uri (uri);
1439 result = gtk_file_chooser_select_file (chooser, file, NULL);
1440 g_object_unref (file);
1446 * gtk_file_chooser_unselect_uri:
1447 * @chooser: a #GtkFileChooser
1448 * @uri: the URI to unselect
1450 * Unselects the file referred to by @uri. If the file
1451 * is not in the current directory, does not exist, or
1452 * is otherwise not currently selected, does nothing.
1457 gtk_file_chooser_unselect_uri (GtkFileChooser *chooser,
1462 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1463 g_return_if_fail (uri != NULL);
1465 file = g_file_new_for_uri (uri);
1466 gtk_file_chooser_unselect_file (chooser, file);
1467 g_object_unref (file);
1471 * gtk_file_chooser_select_all:
1472 * @chooser: a #GtkFileChooser
1474 * Selects all the files in the current folder of a file chooser.
1479 gtk_file_chooser_select_all (GtkFileChooser *chooser)
1481 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1483 GTK_FILE_CHOOSER_GET_IFACE (chooser)->select_all (chooser);
1487 * gtk_file_chooser_unselect_all:
1488 * @chooser: a #GtkFileChooser
1490 * Unselects all the files in the current folder of a file chooser.
1495 gtk_file_chooser_unselect_all (GtkFileChooser *chooser)
1498 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1500 GTK_FILE_CHOOSER_GET_IFACE (chooser)->unselect_all (chooser);
1504 * gtk_file_chooser_get_uris:
1505 * @chooser: a #GtkFileChooser
1507 * Lists all the selected files and subfolders in the current folder of
1508 * @chooser. The returned names are full absolute URIs.
1510 * Return value: (element-type utf8) (transfer full): a #GSList containing the URIs of all selected
1511 * files and subfolders in the current folder. Free the returned list
1512 * with g_slist_free(), and the filenames with g_free().
1517 gtk_file_chooser_get_uris (GtkFileChooser *chooser)
1519 GSList *files, *result;
1521 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1523 files = gtk_file_chooser_get_files (chooser);
1525 result = files_to_strings (files, g_file_get_uri);
1526 g_slist_foreach (files, (GFunc) g_object_unref, NULL);
1527 g_slist_free (files);
1533 * gtk_file_chooser_set_current_folder_uri:
1534 * @chooser: a #GtkFileChooser
1535 * @uri: the URI for the new current folder
1537 * Sets the current folder for @chooser from an URI.
1538 * The user will be shown the full contents of the current folder,
1539 * plus user interface elements for navigating to other folders.
1541 * Return value: %TRUE if the folder could be changed successfully, %FALSE
1547 gtk_file_chooser_set_current_folder_uri (GtkFileChooser *chooser,
1553 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1554 g_return_val_if_fail (uri != NULL, FALSE);
1556 file = g_file_new_for_uri (uri);
1557 result = gtk_file_chooser_set_current_folder_file (chooser, file, NULL);
1558 g_object_unref (file);
1564 * gtk_file_chooser_get_current_folder_uri:
1565 * @chooser: a #GtkFileChooser
1567 * Gets the current folder of @chooser as an URI.
1568 * See gtk_file_chooser_set_current_folder_uri().
1570 * Note that this is the folder that the file chooser is currently displaying
1571 * (e.g. "file:///home/username/Documents"), which is <emphasis>not the same</emphasis>
1572 * as the currently-selected folder if the chooser is in
1573 * %GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER mode
1574 * (e.g. "file:///home/username/Documents/selected-folder/". To get the
1575 * currently-selected folder in that mode, use gtk_file_chooser_get_uri() as the
1576 * usual way to get the selection.
1578 * Return value: the URI for the current folder. Free with g_free(). This
1579 * function will also return %NULL if the file chooser was unable to load the
1580 * last folder that was requested from it; for example, as would be for calling
1581 * gtk_file_chooser_set_current_folder_uri() on a nonexistent folder.
1586 gtk_file_chooser_get_current_folder_uri (GtkFileChooser *chooser)
1591 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1593 file = gtk_file_chooser_get_current_folder_file (chooser);
1597 uri = g_file_get_uri (file);
1598 g_object_unref (file);
1604 * gtk_file_chooser_set_current_folder_file:
1605 * @chooser: a #GtkFileChooser
1606 * @file: the #GFile for the new folder
1607 * @error: (allow-none): location to store error, or %NULL.
1609 * Sets the current folder for @chooser from a #GFile.
1610 * Internal function, see gtk_file_chooser_set_current_folder_uri().
1612 * Return value: %TRUE if the folder could be changed successfully, %FALSE
1618 gtk_file_chooser_set_current_folder_file (GtkFileChooser *chooser,
1622 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1623 g_return_val_if_fail (G_IS_FILE (file), FALSE);
1624 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
1626 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->set_current_folder (chooser, file, error);
1630 * gtk_file_chooser_get_current_folder_file:
1631 * @chooser: a #GtkFileChooser
1633 * Gets the current folder of @chooser as #GFile.
1634 * See gtk_file_chooser_get_current_folder_uri().
1636 * Return value: (transfer full): the #GFile for the current folder.
1641 gtk_file_chooser_get_current_folder_file (GtkFileChooser *chooser)
1643 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1645 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_current_folder (chooser);
1649 * gtk_file_chooser_select_file:
1650 * @chooser: a #GtkFileChooser
1651 * @file: the file to select
1652 * @error: (allow-none): location to store error, or %NULL
1654 * Selects the file referred to by @file. An internal function. See
1655 * _gtk_file_chooser_select_uri().
1657 * Return value: %TRUE if both the folder could be changed and the path was
1658 * selected successfully, %FALSE otherwise.
1663 gtk_file_chooser_select_file (GtkFileChooser *chooser,
1667 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1668 g_return_val_if_fail (G_IS_FILE (file), FALSE);
1669 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
1671 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->select_file (chooser, file, error);
1675 * gtk_file_chooser_unselect_file:
1676 * @chooser: a #GtkFileChooser
1679 * Unselects the file referred to by @file. If the file is not in the current
1680 * directory, does not exist, or is otherwise not currently selected, does nothing.
1685 gtk_file_chooser_unselect_file (GtkFileChooser *chooser,
1688 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1689 g_return_if_fail (G_IS_FILE (file));
1691 GTK_FILE_CHOOSER_GET_IFACE (chooser)->unselect_file (chooser, file);
1695 * gtk_file_chooser_get_files:
1696 * @chooser: a #GtkFileChooser
1698 * Lists all the selected files and subfolders in the current folder of @chooser
1699 * as #GFile. An internal function, see gtk_file_chooser_get_uris().
1701 * Return value: (element-type GFile) (transfer full): a #GSList
1702 * containing a #GFile for each selected file and subfolder in the
1703 * current folder. Free the returned list with g_slist_free(), and
1704 * the files with g_object_unref().
1709 gtk_file_chooser_get_files (GtkFileChooser *chooser)
1711 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1713 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_files (chooser);
1717 * gtk_file_chooser_set_file:
1718 * @chooser: a #GtkFileChooser
1719 * @file: the #GFile to set as current
1720 * @error: (allow-none): location to store the error, or %NULL to ignore errors.
1722 * Sets @file as the current filename for the file chooser, by changing
1723 * to the file's parent folder and actually selecting the file in list. If
1724 * the @chooser is in %GTK_FILE_CHOOSER_ACTION_SAVE mode, the file's base name
1725 * will also appear in the dialog's file name entry.
1727 * If the file name isn't in the current folder of @chooser, then the current
1728 * folder of @chooser will be changed to the folder containing @filename. This
1729 * is equivalent to a sequence of gtk_file_chooser_unselect_all() followed by
1730 * gtk_file_chooser_select_filename().
1732 * Note that the file must exist, or nothing will be done except
1733 * for the directory change.
1735 * If you are implementing a <guimenuitem>File/Save As...</guimenuitem> dialog,
1736 * you should use this function if you already have a file name to which the
1737 * user may save; for example, when the user opens an existing file and then
1738 * does <guimenuitem>File/Save As...</guimenuitem> on it. If you don't have
1739 * a file name already — for example, if the user just created a new
1740 * file and is saving it for the first time, do not call this function.
1741 * Instead, use something similar to this:
1743 * if (document_is_new)
1745 * /* the user just created a new document */
1746 * gtk_file_chooser_set_current_folder_file (chooser, default_file_for_saving);
1747 * gtk_file_chooser_set_current_name (chooser, "Untitled document");
1751 * /* the user edited an existing document */
1752 * gtk_file_chooser_set_file (chooser, existing_file);
1756 * Return value: %TRUE if both the folder could be changed and the file was
1757 * selected successfully, %FALSE otherwise.
1762 gtk_file_chooser_set_file (GtkFileChooser *chooser,
1766 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1767 g_return_val_if_fail (G_IS_FILE (file), FALSE);
1768 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
1770 gtk_file_chooser_unselect_all (chooser);
1771 return gtk_file_chooser_select_file (chooser, file, error);
1775 * gtk_file_chooser_get_file:
1776 * @chooser: a #GtkFileChooser
1778 * Gets the #GFile for the currently selected file in
1779 * the file selector. If multiple files are selected,
1780 * one of the files will be returned at random.
1782 * If the file chooser is in folder mode, this function returns the selected
1785 * Returns: (transfer full): a selected #GFile. You own the returned file;
1786 * use g_object_unref() to release it.
1791 gtk_file_chooser_get_file (GtkFileChooser *chooser)
1794 GFile *result = NULL;
1796 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1798 list = gtk_file_chooser_get_files (chooser);
1801 result = list->data;
1802 list = g_slist_delete_link (list, list);
1804 g_slist_foreach (list, (GFunc) g_object_unref, NULL);
1805 g_slist_free (list);
1812 * _gtk_file_chooser_get_file_system:
1813 * @chooser: a #GtkFileChooser
1815 * Gets the #GtkFileSystem of @chooser; this is an internal
1816 * implementation detail, used for conversion between paths
1817 * and filenames and URIs.
1819 * Return value: the file system for @chooser.
1824 _gtk_file_chooser_get_file_system (GtkFileChooser *chooser)
1826 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1828 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_file_system (chooser);
1834 * gtk_file_chooser_set_preview_widget:
1835 * @chooser: a #GtkFileChooser
1836 * @preview_widget: widget for displaying preview.
1838 * Sets an application-supplied widget to use to display a custom preview
1839 * of the currently selected file. To implement a preview, after setting the
1840 * preview widget, you connect to the #GtkFileChooser::update-preview
1841 * signal, and call gtk_file_chooser_get_preview_filename() or
1842 * gtk_file_chooser_get_preview_uri() on each change. If you can
1843 * display a preview of the new file, update your widget and
1844 * set the preview active using gtk_file_chooser_set_preview_widget_active().
1845 * Otherwise, set the preview inactive.
1847 * When there is no application-supplied preview widget, or the
1848 * application-supplied preview widget is not active, the file chooser
1849 * may display an internally generated preview of the current file or
1850 * it may display no preview at all.
1855 gtk_file_chooser_set_preview_widget (GtkFileChooser *chooser,
1856 GtkWidget *preview_widget)
1858 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1860 g_object_set (chooser, "preview-widget", preview_widget, NULL);
1864 * gtk_file_chooser_get_preview_widget:
1865 * @chooser: a #GtkFileChooser
1867 * Gets the current preview widget; see
1868 * gtk_file_chooser_set_preview_widget().
1870 * Return value: (transfer none): the current preview widget, or %NULL
1875 gtk_file_chooser_get_preview_widget (GtkFileChooser *chooser)
1877 GtkWidget *preview_widget;
1879 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1881 g_object_get (chooser, "preview-widget", &preview_widget, NULL);
1883 /* Horrid hack; g_object_get() refs returned objects but
1884 * that contradicts the memory management conventions
1888 g_object_unref (preview_widget);
1890 return preview_widget;
1894 * gtk_file_chooser_set_preview_widget_active:
1895 * @chooser: a #GtkFileChooser
1896 * @active: whether to display the user-specified preview widget
1898 * Sets whether the preview widget set by
1899 * gtk_file_chooser_set_preview_widget() should be shown for the
1900 * current filename. When @active is set to false, the file chooser
1901 * may display an internally generated preview of the current file
1902 * or it may display no preview at all. See
1903 * gtk_file_chooser_set_preview_widget() for more details.
1908 gtk_file_chooser_set_preview_widget_active (GtkFileChooser *chooser,
1911 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1913 g_object_set (chooser, "preview-widget-active", active, NULL);
1917 * gtk_file_chooser_get_preview_widget_active:
1918 * @chooser: a #GtkFileChooser
1920 * Gets whether the preview widget set by gtk_file_chooser_set_preview_widget()
1921 * should be shown for the current filename. See
1922 * gtk_file_chooser_set_preview_widget_active().
1924 * Return value: %TRUE if the preview widget is active for the current filename.
1929 gtk_file_chooser_get_preview_widget_active (GtkFileChooser *chooser)
1933 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1935 g_object_get (chooser, "preview-widget-active", &active, NULL);
1941 * gtk_file_chooser_set_use_preview_label:
1942 * @chooser: a #GtkFileChooser
1943 * @use_label: whether to display a stock label with the name of the previewed file
1945 * Sets whether the file chooser should display a stock label with the name of
1946 * the file that is being previewed; the default is %TRUE. Applications that
1947 * want to draw the whole preview area themselves should set this to %FALSE and
1948 * display the name themselves in their preview widget.
1950 * See also: gtk_file_chooser_set_preview_widget()
1955 gtk_file_chooser_set_use_preview_label (GtkFileChooser *chooser,
1958 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1960 g_object_set (chooser, "use-preview-label", use_label, NULL);
1964 * gtk_file_chooser_get_use_preview_label:
1965 * @chooser: a #GtkFileChooser
1967 * Gets whether a stock label should be drawn with the name of the previewed
1968 * file. See gtk_file_chooser_set_use_preview_label().
1970 * Return value: %TRUE if the file chooser is set to display a label with the
1971 * name of the previewed file, %FALSE otherwise.
1974 gtk_file_chooser_get_use_preview_label (GtkFileChooser *chooser)
1978 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1980 g_object_get (chooser, "use-preview-label", &use_label, NULL);
1986 * gtk_file_chooser_get_preview_file:
1987 * @chooser: a #GtkFileChooser
1989 * Gets the #GFile that should be previewed in a custom preview
1990 * Internal function, see gtk_file_chooser_get_preview_uri().
1992 * Return value: (transfer full): the #GFile for the file to preview,
1993 * or %NULL if no file is selected. Free with g_object_unref().
1998 gtk_file_chooser_get_preview_file (GtkFileChooser *chooser)
2000 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2002 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_preview_file (chooser);
2006 * _gtk_file_chooser_add_shortcut_folder:
2007 * @chooser: a #GtkFileChooser
2008 * @file: file for the folder to add
2009 * @error: (allow-none): location to store error, or %NULL
2011 * Adds a folder to be displayed with the shortcut folders in a file chooser.
2012 * Internal function, see gtk_file_chooser_add_shortcut_folder().
2014 * Return value: %TRUE if the folder could be added successfully, %FALSE
2020 _gtk_file_chooser_add_shortcut_folder (GtkFileChooser *chooser,
2024 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2025 g_return_val_if_fail (G_IS_FILE (file), FALSE);
2027 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_shortcut_folder (chooser, file, error);
2031 * _gtk_file_chooser_remove_shortcut_folder:
2032 * @chooser: a #GtkFileChooser
2033 * @file: file for the folder to remove
2034 * @error: (allow-none): location to store error, or %NULL
2036 * Removes a folder from the shortcut folders in a file chooser. Internal
2037 * function, see gtk_file_chooser_remove_shortcut_folder().
2039 * Return value: %TRUE if the folder could be removed successfully, %FALSE
2045 _gtk_file_chooser_remove_shortcut_folder (GtkFileChooser *chooser,
2049 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2050 g_return_val_if_fail (G_IS_FILE (file), FALSE);
2052 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_shortcut_folder (chooser, file, error);
2056 * gtk_file_chooser_get_preview_filename:
2057 * @chooser: a #GtkFileChooser
2059 * Gets the filename that should be previewed in a custom preview
2060 * widget. See gtk_file_chooser_set_preview_widget().
2062 * Return value: (type filename): the filename to preview, or %NULL if
2063 * no file is selected, or if the selected file cannot be represented
2064 * as a local filename. Free with g_free()
2069 gtk_file_chooser_get_preview_filename (GtkFileChooser *chooser)
2072 gchar *result = NULL;
2074 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2076 file = gtk_file_chooser_get_preview_file (chooser);
2079 result = g_file_get_path (file);
2080 g_object_unref (file);
2087 * gtk_file_chooser_get_preview_uri:
2088 * @chooser: a #GtkFileChooser
2090 * Gets the URI that should be previewed in a custom preview
2091 * widget. See gtk_file_chooser_set_preview_widget().
2093 * Return value: the URI for the file to preview, or %NULL if no file is
2094 * selected. Free with g_free().
2099 gtk_file_chooser_get_preview_uri (GtkFileChooser *chooser)
2102 gchar *result = NULL;
2104 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2106 file = gtk_file_chooser_get_preview_file (chooser);
2109 result = g_file_get_uri (file);
2110 g_object_unref (file);
2117 * gtk_file_chooser_set_extra_widget:
2118 * @chooser: a #GtkFileChooser
2119 * @extra_widget: widget for extra options
2121 * Sets an application-supplied widget to provide extra options to the user.
2126 gtk_file_chooser_set_extra_widget (GtkFileChooser *chooser,
2127 GtkWidget *extra_widget)
2129 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
2131 g_object_set (chooser, "extra-widget", extra_widget, NULL);
2135 * gtk_file_chooser_get_extra_widget:
2136 * @chooser: a #GtkFileChooser
2138 * Gets the current preview widget; see
2139 * gtk_file_chooser_set_extra_widget().
2141 * Return value: (transfer none): the current extra widget, or %NULL
2146 gtk_file_chooser_get_extra_widget (GtkFileChooser *chooser)
2148 GtkWidget *extra_widget;
2150 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2152 g_object_get (chooser, "extra-widget", &extra_widget, NULL);
2154 /* Horrid hack; g_object_get() refs returned objects but
2155 * that contradicts the memory management conventions
2159 g_object_unref (extra_widget);
2161 return extra_widget;
2165 * gtk_file_chooser_add_filter:
2166 * @chooser: a #GtkFileChooser
2167 * @filter: a #GtkFileFilter
2169 * Adds @filter to the list of filters that the user can select between.
2170 * When a filter is selected, only files that are passed by that
2171 * filter are displayed.
2173 * Note that the @chooser takes ownership of the filter, so you have to
2174 * ref and sink it if you want to keep a reference.
2179 gtk_file_chooser_add_filter (GtkFileChooser *chooser,
2180 GtkFileFilter *filter)
2182 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
2184 GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_filter (chooser, filter);
2188 * gtk_file_chooser_remove_filter:
2189 * @chooser: a #GtkFileChooser
2190 * @filter: a #GtkFileFilter
2192 * Removes @filter from the list of filters that the user can select between.
2197 gtk_file_chooser_remove_filter (GtkFileChooser *chooser,
2198 GtkFileFilter *filter)
2200 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
2202 GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_filter (chooser, filter);
2206 * gtk_file_chooser_list_filters:
2207 * @chooser: a #GtkFileChooser
2209 * Lists the current set of user-selectable filters; see
2210 * gtk_file_chooser_add_filter(), gtk_file_chooser_remove_filter().
2212 * Return value: (element-type GtkFileFilter) (transfer container): a
2213 * #GSList containing the current set of user selectable filters. The
2214 * contents of the list are owned by GTK+, but you must free the list
2215 * itself with g_slist_free() when you are done with it.
2220 gtk_file_chooser_list_filters (GtkFileChooser *chooser)
2222 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2224 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->list_filters (chooser);
2228 * gtk_file_chooser_set_filter:
2229 * @chooser: a #GtkFileChooser
2230 * @filter: a #GtkFileFilter
2232 * Sets the current filter; only the files that pass the
2233 * filter will be displayed. If the user-selectable list of filters
2234 * is non-empty, then the filter should be one of the filters
2235 * in that list. Setting the current filter when the list of
2236 * filters is empty is useful if you want to restrict the displayed
2237 * set of files without letting the user change it.
2242 gtk_file_chooser_set_filter (GtkFileChooser *chooser,
2243 GtkFileFilter *filter)
2245 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
2246 g_return_if_fail (GTK_IS_FILE_FILTER (filter));
2248 g_object_set (chooser, "filter", filter, NULL);
2252 * gtk_file_chooser_get_filter:
2253 * @chooser: a #GtkFileChooser
2255 * Gets the current filter; see gtk_file_chooser_set_filter().
2257 * Return value: (transfer none): the current filter, or %NULL
2262 gtk_file_chooser_get_filter (GtkFileChooser *chooser)
2264 GtkFileFilter *filter;
2266 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2268 g_object_get (chooser, "filter", &filter, NULL);
2269 /* Horrid hack; g_object_get() refs returned objects but
2270 * that contradicts the memory management conventions
2274 g_object_unref (filter);
2280 * gtk_file_chooser_add_shortcut_folder:
2281 * @chooser: a #GtkFileChooser
2282 * @folder: (type filename): filename of the folder to add
2283 * @error: (allow-none): location to store error, or %NULL
2285 * Adds a folder to be displayed with the shortcut folders in a file chooser.
2286 * Note that shortcut folders do not get saved, as they are provided by the
2287 * application. For example, you can use this to add a
2288 * "/usr/share/mydrawprogram/Clipart" folder to the volume list.
2290 * Return value: %TRUE if the folder could be added successfully, %FALSE
2291 * otherwise. In the latter case, the @error will be set as appropriate.
2296 gtk_file_chooser_add_shortcut_folder (GtkFileChooser *chooser,
2303 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2304 g_return_val_if_fail (folder != NULL, FALSE);
2306 file = g_file_new_for_path (folder);
2307 result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_shortcut_folder (chooser, file, error);
2308 g_object_unref (file);
2314 * gtk_file_chooser_remove_shortcut_folder:
2315 * @chooser: a #GtkFileChooser
2316 * @folder: (type filename): filename of the folder to remove
2317 * @error: (allow-none): location to store error, or %NULL
2319 * Removes a folder from a file chooser's list of shortcut folders.
2321 * Return value: %TRUE if the operation succeeds, %FALSE otherwise.
2322 * In the latter case, the @error will be set as appropriate.
2324 * See also: gtk_file_chooser_add_shortcut_folder()
2329 gtk_file_chooser_remove_shortcut_folder (GtkFileChooser *chooser,
2336 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2337 g_return_val_if_fail (folder != NULL, FALSE);
2339 file = g_file_new_for_path (folder);
2340 result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_shortcut_folder (chooser, file, error);
2341 g_object_unref (file);
2347 * gtk_file_chooser_list_shortcut_folders:
2348 * @chooser: a #GtkFileChooser
2350 * Queries the list of shortcut folders in the file chooser, as set by
2351 * gtk_file_chooser_add_shortcut_folder().
2353 * Return value: (element-type filename) (transfer full): A list of
2354 * folder filenames, or %NULL if there are no shortcut folders. Free
2355 * the returned list with g_slist_free(), and the filenames with
2361 gtk_file_chooser_list_shortcut_folders (GtkFileChooser *chooser)
2366 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2368 folders = _gtk_file_chooser_list_shortcut_folder_files (chooser);
2370 result = files_to_strings (folders, g_file_get_path);
2371 g_slist_foreach (folders, (GFunc) g_object_unref, NULL);
2372 g_slist_free (folders);
2378 * gtk_file_chooser_add_shortcut_folder_uri:
2379 * @chooser: a #GtkFileChooser
2380 * @uri: URI of the folder to add
2381 * @error: (allow-none): location to store error, or %NULL
2383 * Adds a folder URI to be displayed with the shortcut folders in a file
2384 * chooser. Note that shortcut folders do not get saved, as they are provided
2385 * by the application. For example, you can use this to add a
2386 * "file:///usr/share/mydrawprogram/Clipart" folder to the volume list.
2388 * Return value: %TRUE if the folder could be added successfully, %FALSE
2389 * otherwise. In the latter case, the @error will be set as appropriate.
2394 gtk_file_chooser_add_shortcut_folder_uri (GtkFileChooser *chooser,
2401 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2402 g_return_val_if_fail (uri != NULL, FALSE);
2404 file = g_file_new_for_uri (uri);
2405 result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_shortcut_folder (chooser, file, error);
2406 g_object_unref (file);
2412 * gtk_file_chooser_remove_shortcut_folder_uri:
2413 * @chooser: a #GtkFileChooser
2414 * @uri: URI of the folder to remove
2415 * @error: (allow-none): location to store error, or %NULL
2417 * Removes a folder URI from a file chooser's list of shortcut folders.
2419 * Return value: %TRUE if the operation succeeds, %FALSE otherwise.
2420 * In the latter case, the @error will be set as appropriate.
2422 * See also: gtk_file_chooser_add_shortcut_folder_uri()
2427 gtk_file_chooser_remove_shortcut_folder_uri (GtkFileChooser *chooser,
2434 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2435 g_return_val_if_fail (uri != NULL, FALSE);
2437 file = g_file_new_for_uri (uri);
2438 result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_shortcut_folder (chooser, file, error);
2439 g_object_unref (file);
2445 * gtk_file_chooser_list_shortcut_folder_uris:
2446 * @chooser: a #GtkFileChooser
2448 * Queries the list of shortcut folders in the file chooser, as set by
2449 * gtk_file_chooser_add_shortcut_folder_uri().
2451 * Return value: (element-type utf8) (transfer full): A list of folder
2452 * URIs, or %NULL if there are no shortcut folders. Free the returned
2453 * list with g_slist_free(), and the URIs with g_free().
2458 gtk_file_chooser_list_shortcut_folder_uris (GtkFileChooser *chooser)
2463 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2465 folders = _gtk_file_chooser_list_shortcut_folder_files (chooser);
2467 result = files_to_strings (folders, g_file_get_uri);
2468 g_slist_foreach (folders, (GFunc) g_object_unref, NULL);
2469 g_slist_free (folders);
2475 _gtk_file_chooser_list_shortcut_folder_files (GtkFileChooser *chooser)
2477 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2479 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->list_shortcut_folders (chooser);
2483 * gtk_file_chooser_set_show_hidden:
2484 * @chooser: a #GtkFileChooser
2485 * @show_hidden: %TRUE if hidden files and folders should be displayed.
2487 * Sets whether hidden files and folders are displayed in the file selector.
2492 gtk_file_chooser_set_show_hidden (GtkFileChooser *chooser,
2493 gboolean show_hidden)
2495 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
2497 g_object_set (chooser, "show-hidden", show_hidden, NULL);
2501 * gtk_file_chooser_get_show_hidden:
2502 * @chooser: a #GtkFileChooser
2504 * Gets whether hidden files and folders are displayed in the file selector.
2505 * See gtk_file_chooser_set_show_hidden().
2507 * Return value: %TRUE if hidden files and folders are displayed.
2512 gtk_file_chooser_get_show_hidden (GtkFileChooser *chooser)
2514 gboolean show_hidden;
2516 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2518 g_object_get (chooser, "show-hidden", &show_hidden, NULL);
2524 * gtk_file_chooser_set_do_overwrite_confirmation:
2525 * @chooser: a #GtkFileChooser
2526 * @do_overwrite_confirmation: whether to confirm overwriting in save mode
2528 * Sets whether a file chooser in %GTK_FILE_CHOOSER_ACTION_SAVE mode will present
2529 * a confirmation dialog if the user types a file name that already exists. This
2530 * is %FALSE by default.
2532 * Regardless of this setting, the @chooser will emit the
2533 * #GtkFileChooser::confirm-overwrite signal when appropriate.
2535 * If all you need is the stock confirmation dialog, set this property to %TRUE.
2536 * You can override the way confirmation is done by actually handling the
2537 * #GtkFileChooser::confirm-overwrite signal; please refer to its documentation
2543 gtk_file_chooser_set_do_overwrite_confirmation (GtkFileChooser *chooser,
2544 gboolean do_overwrite_confirmation)
2546 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
2548 g_object_set (chooser, "do-overwrite-confirmation", do_overwrite_confirmation, NULL);
2552 * gtk_file_chooser_get_do_overwrite_confirmation:
2553 * @chooser: a #GtkFileChooser
2555 * Queries whether a file chooser is set to confirm for overwriting when the user
2556 * types a file name that already exists.
2558 * Return value: %TRUE if the file chooser will present a confirmation dialog;
2564 gtk_file_chooser_get_do_overwrite_confirmation (GtkFileChooser *chooser)
2566 gboolean do_overwrite_confirmation;
2568 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2570 g_object_get (chooser, "do-overwrite-confirmation", &do_overwrite_confirmation, NULL);
2572 return do_overwrite_confirmation;