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: 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: 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: 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: 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 utf8) (transfer full): a #GSList containing the filenames of all selected
1205 * files and subfolders in the current folder. Free the returned list
1206 * with g_slist_free(), and the filenames with g_free().
1211 gtk_file_chooser_get_filenames (GtkFileChooser *chooser)
1213 GSList *files, *result;
1215 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1217 files = gtk_file_chooser_get_files (chooser);
1219 result = files_to_strings (files, g_file_get_path);
1220 g_slist_foreach (files, (GFunc) g_object_unref, NULL);
1221 g_slist_free (files);
1227 * gtk_file_chooser_set_current_folder:
1228 * @chooser: a #GtkFileChooser
1229 * @filename: the full path of the new current folder
1231 * Sets the current folder for @chooser from a local filename.
1232 * The user will be shown the full contents of the current folder,
1233 * plus user interface elements for navigating to other folders.
1235 * Return value: %TRUE if the folder could be changed successfully, %FALSE
1241 gtk_file_chooser_set_current_folder (GtkFileChooser *chooser,
1242 const gchar *filename)
1247 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1248 g_return_val_if_fail (filename != NULL, FALSE);
1250 file = g_file_new_for_path (filename);
1251 result = gtk_file_chooser_set_current_folder_file (chooser, file, NULL);
1252 g_object_unref (file);
1258 * gtk_file_chooser_get_current_folder:
1259 * @chooser: a #GtkFileChooser
1261 * Gets the current folder of @chooser as a local filename.
1262 * See gtk_file_chooser_set_current_folder().
1264 * Note that this is the folder that the file chooser is currently displaying
1265 * (e.g. "/home/username/Documents"), which is <emphasis>not the same</emphasis>
1266 * as the currently-selected folder if the chooser is in
1267 * %GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER mode
1268 * (e.g. "/home/username/Documents/selected-folder/". To get the
1269 * currently-selected folder in that mode, use gtk_file_chooser_get_uri() as the
1270 * usual way to get the selection.
1272 * Return value: the full path of the current folder, or %NULL if the current
1273 * path cannot be represented as a local filename. Free with g_free(). This
1274 * function will also return %NULL if the file chooser was unable to load the
1275 * last folder that was requested from it; for example, as would be for calling
1276 * gtk_file_chooser_set_current_folder() on a nonexistent folder.
1281 gtk_file_chooser_get_current_folder (GtkFileChooser *chooser)
1286 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1288 file = gtk_file_chooser_get_current_folder_file (chooser);
1292 filename = g_file_get_path (file);
1293 g_object_unref (file);
1299 * gtk_file_chooser_set_current_name:
1300 * @chooser: a #GtkFileChooser
1301 * @name: the filename to use, as a UTF-8 string
1303 * Sets the current name in the file selector, as if entered
1304 * by the user. Note that the name passed in here is a UTF-8
1305 * string rather than a filename. This function is meant for
1306 * such uses as a suggested name in a "Save As..." dialog.
1308 * If you want to preselect a particular existing file, you should use
1309 * gtk_file_chooser_set_filename() or gtk_file_chooser_set_uri() instead.
1310 * Please see the documentation for those functions for an example of using
1311 * gtk_file_chooser_set_current_name() as well.
1316 gtk_file_chooser_set_current_name (GtkFileChooser *chooser,
1319 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1320 g_return_if_fail (name != NULL);
1322 GTK_FILE_CHOOSER_GET_IFACE (chooser)->set_current_name (chooser, name);
1326 * gtk_file_chooser_get_uri:
1327 * @chooser: a #GtkFileChooser
1329 * Gets the URI for the currently selected file in
1330 * the file selector. If multiple files are selected,
1331 * one of the filenames will be returned at random.
1333 * If the file chooser is in folder mode, this function returns the selected
1336 * Return value: The currently selected URI, or %NULL
1337 * if no file is selected. Free with g_free()
1342 gtk_file_chooser_get_uri (GtkFileChooser *chooser)
1345 gchar *result = NULL;
1347 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1349 file = gtk_file_chooser_get_file (chooser);
1352 result = g_file_get_uri (file);
1353 g_object_unref (file);
1360 * gtk_file_chooser_set_uri:
1361 * @chooser: a #GtkFileChooser
1362 * @uri: the URI to set as current
1364 * Sets the file referred to by @uri as the current file for the file chooser,
1365 * by changing to the URI's parent folder and actually selecting the URI in the
1366 * list. If the @chooser is %GTK_FILE_CHOOSER_ACTION_SAVE mode, the URI's base
1367 * name will also appear in the dialog's file name entry.
1369 * If the URI isn't in the current folder of @chooser, then the current folder
1370 * of @chooser will be changed to the folder containing @uri. This is equivalent
1371 * to a sequence of gtk_file_chooser_unselect_all() followed by
1372 * gtk_file_chooser_select_uri().
1374 * Note that the URI must exist, or nothing will be done except for the
1376 * If you are implementing a <guimenuitem>File/Save As...</guimenuitem> dialog,
1377 * you should use this function if you already have a file name to which the
1378 * user may save; for example, when the user opens an existing file and then
1379 * does <guimenuitem>File/Save As...</guimenuitem> on it. If you don't have
1380 * a file name already — for example, if the user just created a new
1381 * file and is saving it for the first time, do not call this function.
1382 * Instead, use something similar to this:
1384 * if (document_is_new)
1386 * /* the user just created a new document */
1387 * gtk_file_chooser_set_current_folder_uri (chooser, default_folder_for_saving);
1388 * gtk_file_chooser_set_current_name (chooser, "Untitled document");
1392 * /* the user edited an existing document */
1393 * gtk_file_chooser_set_uri (chooser, existing_uri);
1397 * Return value: %TRUE if both the folder could be changed and the URI was
1398 * selected successfully, %FALSE otherwise.
1403 gtk_file_chooser_set_uri (GtkFileChooser *chooser,
1406 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1408 gtk_file_chooser_unselect_all (chooser);
1409 return gtk_file_chooser_select_uri (chooser, uri);
1413 * gtk_file_chooser_select_uri:
1414 * @chooser: a #GtkFileChooser
1415 * @uri: the URI to select
1417 * Selects the file to by @uri. If the URI doesn't refer to a
1418 * file in the current folder of @chooser, then the current folder of
1419 * @chooser will be changed to the folder containing @filename.
1421 * Return value: %TRUE if both the folder could be changed and the URI was
1422 * selected successfully, %FALSE otherwise.
1427 gtk_file_chooser_select_uri (GtkFileChooser *chooser,
1433 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1434 g_return_val_if_fail (uri != NULL, FALSE);
1436 file = g_file_new_for_uri (uri);
1437 result = gtk_file_chooser_select_file (chooser, file, NULL);
1438 g_object_unref (file);
1444 * gtk_file_chooser_unselect_uri:
1445 * @chooser: a #GtkFileChooser
1446 * @uri: the URI to unselect
1448 * Unselects the file referred to by @uri. If the file
1449 * is not in the current directory, does not exist, or
1450 * is otherwise not currently selected, does nothing.
1455 gtk_file_chooser_unselect_uri (GtkFileChooser *chooser,
1460 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1461 g_return_if_fail (uri != NULL);
1463 file = g_file_new_for_uri (uri);
1464 gtk_file_chooser_unselect_file (chooser, file);
1465 g_object_unref (file);
1469 * gtk_file_chooser_select_all:
1470 * @chooser: a #GtkFileChooser
1472 * Selects all the files in the current folder of a file chooser.
1477 gtk_file_chooser_select_all (GtkFileChooser *chooser)
1479 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1481 GTK_FILE_CHOOSER_GET_IFACE (chooser)->select_all (chooser);
1485 * gtk_file_chooser_unselect_all:
1486 * @chooser: a #GtkFileChooser
1488 * Unselects all the files in the current folder of a file chooser.
1493 gtk_file_chooser_unselect_all (GtkFileChooser *chooser)
1496 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1498 GTK_FILE_CHOOSER_GET_IFACE (chooser)->unselect_all (chooser);
1502 * gtk_file_chooser_get_uris:
1503 * @chooser: a #GtkFileChooser
1505 * Lists all the selected files and subfolders in the current folder of
1506 * @chooser. The returned names are full absolute URIs.
1508 * Return value: (element-type utf8) (transfer full): a #GSList containing the URIs of all selected
1509 * files and subfolders in the current folder. Free the returned list
1510 * with g_slist_free(), and the filenames with g_free().
1515 gtk_file_chooser_get_uris (GtkFileChooser *chooser)
1517 GSList *files, *result;
1519 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1521 files = gtk_file_chooser_get_files (chooser);
1523 result = files_to_strings (files, g_file_get_uri);
1524 g_slist_foreach (files, (GFunc) g_object_unref, NULL);
1525 g_slist_free (files);
1531 * gtk_file_chooser_set_current_folder_uri:
1532 * @chooser: a #GtkFileChooser
1533 * @uri: the URI for the new current folder
1535 * Sets the current folder for @chooser from an URI.
1536 * The user will be shown the full contents of the current folder,
1537 * plus user interface elements for navigating to other folders.
1539 * Return value: %TRUE if the folder could be changed successfully, %FALSE
1545 gtk_file_chooser_set_current_folder_uri (GtkFileChooser *chooser,
1551 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1552 g_return_val_if_fail (uri != NULL, FALSE);
1554 file = g_file_new_for_uri (uri);
1555 result = gtk_file_chooser_set_current_folder_file (chooser, file, NULL);
1556 g_object_unref (file);
1562 * gtk_file_chooser_get_current_folder_uri:
1563 * @chooser: a #GtkFileChooser
1565 * Gets the current folder of @chooser as an URI.
1566 * See gtk_file_chooser_set_current_folder_uri().
1568 * Note that this is the folder that the file chooser is currently displaying
1569 * (e.g. "file:///home/username/Documents"), which is <emphasis>not the same</emphasis>
1570 * as the currently-selected folder if the chooser is in
1571 * %GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER mode
1572 * (e.g. "file:///home/username/Documents/selected-folder/". To get the
1573 * currently-selected folder in that mode, use gtk_file_chooser_get_uri() as the
1574 * usual way to get the selection.
1576 * Return value: the URI for the current folder. Free with g_free(). This
1577 * function will also return %NULL if the file chooser was unable to load the
1578 * last folder that was requested from it; for example, as would be for calling
1579 * gtk_file_chooser_set_current_folder_uri() on a nonexistent folder.
1584 gtk_file_chooser_get_current_folder_uri (GtkFileChooser *chooser)
1589 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1591 file = gtk_file_chooser_get_current_folder_file (chooser);
1595 uri = g_file_get_uri (file);
1596 g_object_unref (file);
1602 * gtk_file_chooser_set_current_folder_file:
1603 * @chooser: a #GtkFileChooser
1604 * @file: the #GFile for the new folder
1605 * @error: (allow-none): location to store error, or %NULL.
1607 * Sets the current folder for @chooser from a #GFile.
1608 * Internal function, see gtk_file_chooser_set_current_folder_uri().
1610 * Return value: %TRUE if the folder could be changed successfully, %FALSE
1616 gtk_file_chooser_set_current_folder_file (GtkFileChooser *chooser,
1620 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1621 g_return_val_if_fail (G_IS_FILE (file), FALSE);
1622 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
1624 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->set_current_folder (chooser, file, error);
1628 * gtk_file_chooser_get_current_folder_file:
1629 * @chooser: a #GtkFileChooser
1631 * Gets the current folder of @chooser as #GFile.
1632 * See gtk_file_chooser_get_current_folder_uri().
1634 * Return value: (transfer full): the #GFile for the current folder.
1639 gtk_file_chooser_get_current_folder_file (GtkFileChooser *chooser)
1641 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1643 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_current_folder (chooser);
1647 * gtk_file_chooser_select_file:
1648 * @chooser: a #GtkFileChooser
1649 * @file: the file to select
1650 * @error: (allow-none): location to store error, or %NULL
1652 * Selects the file referred to by @file. An internal function. See
1653 * _gtk_file_chooser_select_uri().
1655 * Return value: %TRUE if both the folder could be changed and the path was
1656 * selected successfully, %FALSE otherwise.
1661 gtk_file_chooser_select_file (GtkFileChooser *chooser,
1665 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1666 g_return_val_if_fail (G_IS_FILE (file), FALSE);
1667 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
1669 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->select_file (chooser, file, error);
1673 * gtk_file_chooser_unselect_file:
1674 * @chooser: a #GtkFileChooser
1677 * Unselects the file referred to by @file. If the file is not in the current
1678 * directory, does not exist, or is otherwise not currently selected, does nothing.
1683 gtk_file_chooser_unselect_file (GtkFileChooser *chooser,
1686 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1687 g_return_if_fail (G_IS_FILE (file));
1689 GTK_FILE_CHOOSER_GET_IFACE (chooser)->unselect_file (chooser, file);
1693 * gtk_file_chooser_get_files:
1694 * @chooser: a #GtkFileChooser
1696 * Lists all the selected files and subfolders in the current folder of @chooser
1697 * as #GFile. An internal function, see gtk_file_chooser_get_uris().
1699 * Return value: (element-type utf8) (transfer full): a #GSList containing a #GFile for each selected
1700 * file and subfolder in the current folder. Free the returned list
1701 * with g_slist_free(), and the files with g_object_unref().
1706 gtk_file_chooser_get_files (GtkFileChooser *chooser)
1708 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1710 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_files (chooser);
1714 * gtk_file_chooser_set_file:
1715 * @chooser: a #GtkFileChooser
1716 * @file: the #GFile to set as current
1717 * @error: (allow-none): location to store the error, or %NULL to ignore errors.
1719 * Sets @file as the current filename for the file chooser, by changing
1720 * to the file's parent folder and actually selecting the file in list. If
1721 * the @chooser is in %GTK_FILE_CHOOSER_ACTION_SAVE mode, the file's base name
1722 * will also appear in the dialog's file name entry.
1724 * If the file name isn't in the current folder of @chooser, then the current
1725 * folder of @chooser will be changed to the folder containing @filename. This
1726 * is equivalent to a sequence of gtk_file_chooser_unselect_all() followed by
1727 * gtk_file_chooser_select_filename().
1729 * Note that the file must exist, or nothing will be done except
1730 * for the directory change.
1732 * If you are implementing a <guimenuitem>File/Save As...</guimenuitem> dialog,
1733 * you should use this function if you already have a file name to which the
1734 * user may save; for example, when the user opens an existing file and then
1735 * does <guimenuitem>File/Save As...</guimenuitem> on it. If you don't have
1736 * a file name already — for example, if the user just created a new
1737 * file and is saving it for the first time, do not call this function.
1738 * Instead, use something similar to this:
1740 * if (document_is_new)
1742 * /* the user just created a new document */
1743 * gtk_file_chooser_set_current_folder_file (chooser, default_file_for_saving);
1744 * gtk_file_chooser_set_current_name (chooser, "Untitled document");
1748 * /* the user edited an existing document */
1749 * gtk_file_chooser_set_file (chooser, existing_file);
1753 * Return value: %TRUE if both the folder could be changed and the file was
1754 * selected successfully, %FALSE otherwise.
1759 gtk_file_chooser_set_file (GtkFileChooser *chooser,
1763 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1764 g_return_val_if_fail (G_IS_FILE (file), FALSE);
1765 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
1767 gtk_file_chooser_unselect_all (chooser);
1768 return gtk_file_chooser_select_file (chooser, file, error);
1772 * gtk_file_chooser_get_file:
1773 * @chooser: a #GtkFileChooser
1775 * Gets the #GFile for the currently selected file in
1776 * the file selector. If multiple files are selected,
1777 * one of the files will be returned at random.
1779 * If the file chooser is in folder mode, this function returns the selected
1782 * Returns: (transfer full): a selected #GFile. You own the returned file;
1783 * use g_object_unref() to release it.
1788 gtk_file_chooser_get_file (GtkFileChooser *chooser)
1791 GFile *result = NULL;
1793 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1795 list = gtk_file_chooser_get_files (chooser);
1798 result = list->data;
1799 list = g_slist_delete_link (list, list);
1801 g_slist_foreach (list, (GFunc) g_object_unref, NULL);
1802 g_slist_free (list);
1809 * _gtk_file_chooser_get_file_system:
1810 * @chooser: a #GtkFileChooser
1812 * Gets the #GtkFileSystem of @chooser; this is an internal
1813 * implementation detail, used for conversion between paths
1814 * and filenames and URIs.
1816 * Return value: the file system for @chooser.
1821 _gtk_file_chooser_get_file_system (GtkFileChooser *chooser)
1823 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1825 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_file_system (chooser);
1831 * gtk_file_chooser_set_preview_widget:
1832 * @chooser: a #GtkFileChooser
1833 * @preview_widget: widget for displaying preview.
1835 * Sets an application-supplied widget to use to display a custom preview
1836 * of the currently selected file. To implement a preview, after setting the
1837 * preview widget, you connect to the #GtkFileChooser::update-preview
1838 * signal, and call gtk_file_chooser_get_preview_filename() or
1839 * gtk_file_chooser_get_preview_uri() on each change. If you can
1840 * display a preview of the new file, update your widget and
1841 * set the preview active using gtk_file_chooser_set_preview_widget_active().
1842 * Otherwise, set the preview inactive.
1844 * When there is no application-supplied preview widget, or the
1845 * application-supplied preview widget is not active, the file chooser
1846 * may display an internally generated preview of the current file or
1847 * it may display no preview at all.
1852 gtk_file_chooser_set_preview_widget (GtkFileChooser *chooser,
1853 GtkWidget *preview_widget)
1855 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1857 g_object_set (chooser, "preview-widget", preview_widget, NULL);
1861 * gtk_file_chooser_get_preview_widget:
1862 * @chooser: a #GtkFileChooser
1864 * Gets the current preview widget; see
1865 * gtk_file_chooser_set_preview_widget().
1867 * Return value: (transfer none): the current preview widget, or %NULL
1872 gtk_file_chooser_get_preview_widget (GtkFileChooser *chooser)
1874 GtkWidget *preview_widget;
1876 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1878 g_object_get (chooser, "preview-widget", &preview_widget, NULL);
1880 /* Horrid hack; g_object_get() refs returned objects but
1881 * that contradicts the memory management conventions
1885 g_object_unref (preview_widget);
1887 return preview_widget;
1891 * gtk_file_chooser_set_preview_widget_active:
1892 * @chooser: a #GtkFileChooser
1893 * @active: whether to display the user-specified preview widget
1895 * Sets whether the preview widget set by
1896 * gtk_file_chooser_set_preview_widget() should be shown for the
1897 * current filename. When @active is set to false, the file chooser
1898 * may display an internally generated preview of the current file
1899 * or it may display no preview at all. See
1900 * gtk_file_chooser_set_preview_widget() for more details.
1905 gtk_file_chooser_set_preview_widget_active (GtkFileChooser *chooser,
1908 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1910 g_object_set (chooser, "preview-widget-active", active, NULL);
1914 * gtk_file_chooser_get_preview_widget_active:
1915 * @chooser: a #GtkFileChooser
1917 * Gets whether the preview widget set by gtk_file_chooser_set_preview_widget()
1918 * should be shown for the current filename. See
1919 * gtk_file_chooser_set_preview_widget_active().
1921 * Return value: %TRUE if the preview widget is active for the current filename.
1926 gtk_file_chooser_get_preview_widget_active (GtkFileChooser *chooser)
1930 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1932 g_object_get (chooser, "preview-widget-active", &active, NULL);
1938 * gtk_file_chooser_set_use_preview_label:
1939 * @chooser: a #GtkFileChooser
1940 * @use_label: whether to display a stock label with the name of the previewed file
1942 * Sets whether the file chooser should display a stock label with the name of
1943 * the file that is being previewed; the default is %TRUE. Applications that
1944 * want to draw the whole preview area themselves should set this to %FALSE and
1945 * display the name themselves in their preview widget.
1947 * See also: gtk_file_chooser_set_preview_widget()
1952 gtk_file_chooser_set_use_preview_label (GtkFileChooser *chooser,
1955 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1957 g_object_set (chooser, "use-preview-label", use_label, NULL);
1961 * gtk_file_chooser_get_use_preview_label:
1962 * @chooser: a #GtkFileChooser
1964 * Gets whether a stock label should be drawn with the name of the previewed
1965 * file. See gtk_file_chooser_set_use_preview_label().
1967 * Return value: %TRUE if the file chooser is set to display a label with the
1968 * name of the previewed file, %FALSE otherwise.
1971 gtk_file_chooser_get_use_preview_label (GtkFileChooser *chooser)
1975 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1977 g_object_get (chooser, "use-preview-label", &use_label, NULL);
1983 * gtk_file_chooser_get_preview_file:
1984 * @chooser: a #GtkFileChooser
1986 * Gets the #GFile that should be previewed in a custom preview
1987 * Internal function, see gtk_file_chooser_get_preview_uri().
1989 * Return value: (transfer none): the #GFile for the file to preview,
1990 * or %NULL if no file is selected. Free with g_object_unref().
1995 gtk_file_chooser_get_preview_file (GtkFileChooser *chooser)
1997 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1999 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_preview_file (chooser);
2003 * _gtk_file_chooser_add_shortcut_folder:
2004 * @chooser: a #GtkFileChooser
2005 * @file: file for the folder to add
2006 * @error: (allow-none): location to store error, or %NULL
2008 * Adds a folder to be displayed with the shortcut folders in a file chooser.
2009 * Internal function, see gtk_file_chooser_add_shortcut_folder().
2011 * Return value: %TRUE if the folder could be added successfully, %FALSE
2017 _gtk_file_chooser_add_shortcut_folder (GtkFileChooser *chooser,
2021 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2022 g_return_val_if_fail (G_IS_FILE (file), FALSE);
2024 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_shortcut_folder (chooser, file, error);
2028 * _gtk_file_chooser_remove_shortcut_folder:
2029 * @chooser: a #GtkFileChooser
2030 * @file: file for the folder to remove
2031 * @error: (allow-none): location to store error, or %NULL
2033 * Removes a folder from the shortcut folders in a file chooser. Internal
2034 * function, see gtk_file_chooser_remove_shortcut_folder().
2036 * Return value: %TRUE if the folder could be removed successfully, %FALSE
2042 _gtk_file_chooser_remove_shortcut_folder (GtkFileChooser *chooser,
2046 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2047 g_return_val_if_fail (G_IS_FILE (file), FALSE);
2049 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_shortcut_folder (chooser, file, error);
2053 * gtk_file_chooser_get_preview_filename:
2054 * @chooser: a #GtkFileChooser
2056 * Gets the filename that should be previewed in a custom preview
2057 * widget. See gtk_file_chooser_set_preview_widget().
2059 * Return value: the filename to preview, or %NULL if no file
2060 * is selected, or if the selected file cannot be represented
2061 * as a local filename. Free with g_free()
2066 gtk_file_chooser_get_preview_filename (GtkFileChooser *chooser)
2069 gchar *result = NULL;
2071 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2073 file = gtk_file_chooser_get_preview_file (chooser);
2076 result = g_file_get_path (file);
2077 g_object_unref (file);
2084 * gtk_file_chooser_get_preview_uri:
2085 * @chooser: a #GtkFileChooser
2087 * Gets the URI that should be previewed in a custom preview
2088 * widget. See gtk_file_chooser_set_preview_widget().
2090 * Return value: the URI for the file to preview, or %NULL if no file is
2091 * selected. Free with g_free().
2096 gtk_file_chooser_get_preview_uri (GtkFileChooser *chooser)
2099 gchar *result = NULL;
2101 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2103 file = gtk_file_chooser_get_preview_file (chooser);
2106 result = g_file_get_uri (file);
2107 g_object_unref (file);
2114 * gtk_file_chooser_set_extra_widget:
2115 * @chooser: a #GtkFileChooser
2116 * @extra_widget: widget for extra options
2118 * Sets an application-supplied widget to provide extra options to the user.
2123 gtk_file_chooser_set_extra_widget (GtkFileChooser *chooser,
2124 GtkWidget *extra_widget)
2126 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
2128 g_object_set (chooser, "extra-widget", extra_widget, NULL);
2132 * gtk_file_chooser_get_extra_widget:
2133 * @chooser: a #GtkFileChooser
2135 * Gets the current preview widget; see
2136 * gtk_file_chooser_set_extra_widget().
2138 * Return value: (transfer none): the current extra widget, or %NULL
2143 gtk_file_chooser_get_extra_widget (GtkFileChooser *chooser)
2145 GtkWidget *extra_widget;
2147 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2149 g_object_get (chooser, "extra-widget", &extra_widget, NULL);
2151 /* Horrid hack; g_object_get() refs returned objects but
2152 * that contradicts the memory management conventions
2156 g_object_unref (extra_widget);
2158 return extra_widget;
2162 * gtk_file_chooser_add_filter:
2163 * @chooser: a #GtkFileChooser
2164 * @filter: a #GtkFileFilter
2166 * Adds @filter to the list of filters that the user can select between.
2167 * When a filter is selected, only files that are passed by that
2168 * filter are displayed.
2170 * Note that the @chooser takes ownership of the filter, so you have to
2171 * ref and sink it if you want to keep a reference.
2176 gtk_file_chooser_add_filter (GtkFileChooser *chooser,
2177 GtkFileFilter *filter)
2179 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
2181 GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_filter (chooser, filter);
2185 * gtk_file_chooser_remove_filter:
2186 * @chooser: a #GtkFileChooser
2187 * @filter: a #GtkFileFilter
2189 * Removes @filter from the list of filters that the user can select between.
2194 gtk_file_chooser_remove_filter (GtkFileChooser *chooser,
2195 GtkFileFilter *filter)
2197 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
2199 GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_filter (chooser, filter);
2203 * gtk_file_chooser_list_filters:
2204 * @chooser: a #GtkFileChooser
2206 * Lists the current set of user-selectable filters; see
2207 * gtk_file_chooser_add_filter(), gtk_file_chooser_remove_filter().
2209 * Return value: (element-type utf8) (transfer container): a #GSList containing the current set of
2210 * user selectable filters. The contents of the list are
2211 * owned by GTK+, but you must free the list itself with
2212 * g_slist_free() when you are done with it.
2217 gtk_file_chooser_list_filters (GtkFileChooser *chooser)
2219 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2221 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->list_filters (chooser);
2225 * gtk_file_chooser_set_filter:
2226 * @chooser: a #GtkFileChooser
2227 * @filter: a #GtkFileFilter
2229 * Sets the current filter; only the files that pass the
2230 * filter will be displayed. If the user-selectable list of filters
2231 * is non-empty, then the filter should be one of the filters
2232 * in that list. Setting the current filter when the list of
2233 * filters is empty is useful if you want to restrict the displayed
2234 * set of files without letting the user change it.
2239 gtk_file_chooser_set_filter (GtkFileChooser *chooser,
2240 GtkFileFilter *filter)
2242 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
2243 g_return_if_fail (GTK_IS_FILE_FILTER (filter));
2245 g_object_set (chooser, "filter", filter, NULL);
2249 * gtk_file_chooser_get_filter:
2250 * @chooser: a #GtkFileChooser
2252 * Gets the current filter; see gtk_file_chooser_set_filter().
2254 * Return value: (transfer none): the current filter, or %NULL
2259 gtk_file_chooser_get_filter (GtkFileChooser *chooser)
2261 GtkFileFilter *filter;
2263 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2265 g_object_get (chooser, "filter", &filter, NULL);
2266 /* Horrid hack; g_object_get() refs returned objects but
2267 * that contradicts the memory management conventions
2271 g_object_unref (filter);
2277 * gtk_file_chooser_add_shortcut_folder:
2278 * @chooser: a #GtkFileChooser
2279 * @folder: filename of the folder to add
2280 * @error: (allow-none): location to store error, or %NULL
2282 * Adds a folder to be displayed with the shortcut folders in a file chooser.
2283 * Note that shortcut folders do not get saved, as they are provided by the
2284 * application. For example, you can use this to add a
2285 * "/usr/share/mydrawprogram/Clipart" folder to the volume list.
2287 * Return value: %TRUE if the folder could be added successfully, %FALSE
2288 * otherwise. In the latter case, the @error will be set as appropriate.
2293 gtk_file_chooser_add_shortcut_folder (GtkFileChooser *chooser,
2300 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2301 g_return_val_if_fail (folder != NULL, FALSE);
2303 file = g_file_new_for_path (folder);
2304 result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_shortcut_folder (chooser, file, error);
2305 g_object_unref (file);
2311 * gtk_file_chooser_remove_shortcut_folder:
2312 * @chooser: a #GtkFileChooser
2313 * @folder: filename of the folder to remove
2314 * @error: (allow-none): location to store error, or %NULL
2316 * Removes a folder from a file chooser's list of shortcut folders.
2318 * Return value: %TRUE if the operation succeeds, %FALSE otherwise.
2319 * In the latter case, the @error will be set as appropriate.
2321 * See also: gtk_file_chooser_add_shortcut_folder()
2326 gtk_file_chooser_remove_shortcut_folder (GtkFileChooser *chooser,
2333 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2334 g_return_val_if_fail (folder != NULL, FALSE);
2336 file = g_file_new_for_path (folder);
2337 result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_shortcut_folder (chooser, file, error);
2338 g_object_unref (file);
2344 * gtk_file_chooser_list_shortcut_folders:
2345 * @chooser: a #GtkFileChooser
2347 * Queries the list of shortcut folders in the file chooser, as set by
2348 * gtk_file_chooser_add_shortcut_folder().
2350 * Return value: (element-type utf8) (transfer full): A list of folder filenames, or %NULL if there are no shortcut
2351 * folders. Free the returned list with g_slist_free(), and the filenames with
2357 gtk_file_chooser_list_shortcut_folders (GtkFileChooser *chooser)
2362 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2364 folders = _gtk_file_chooser_list_shortcut_folder_files (chooser);
2366 result = files_to_strings (folders, g_file_get_path);
2367 g_slist_foreach (folders, (GFunc) g_object_unref, NULL);
2368 g_slist_free (folders);
2374 * gtk_file_chooser_add_shortcut_folder_uri:
2375 * @chooser: a #GtkFileChooser
2376 * @uri: URI of the folder to add
2377 * @error: (allow-none): location to store error, or %NULL
2379 * Adds a folder URI to be displayed with the shortcut folders in a file
2380 * chooser. Note that shortcut folders do not get saved, as they are provided
2381 * by the application. For example, you can use this to add a
2382 * "file:///usr/share/mydrawprogram/Clipart" folder to the volume list.
2384 * Return value: %TRUE if the folder could be added successfully, %FALSE
2385 * otherwise. In the latter case, the @error will be set as appropriate.
2390 gtk_file_chooser_add_shortcut_folder_uri (GtkFileChooser *chooser,
2397 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2398 g_return_val_if_fail (uri != NULL, FALSE);
2400 file = g_file_new_for_uri (uri);
2401 result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_shortcut_folder (chooser, file, error);
2402 g_object_unref (file);
2408 * gtk_file_chooser_remove_shortcut_folder_uri:
2409 * @chooser: a #GtkFileChooser
2410 * @uri: URI of the folder to remove
2411 * @error: (allow-none): location to store error, or %NULL
2413 * Removes a folder URI from a file chooser's list of shortcut folders.
2415 * Return value: %TRUE if the operation succeeds, %FALSE otherwise.
2416 * In the latter case, the @error will be set as appropriate.
2418 * See also: gtk_file_chooser_add_shortcut_folder_uri()
2423 gtk_file_chooser_remove_shortcut_folder_uri (GtkFileChooser *chooser,
2430 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2431 g_return_val_if_fail (uri != NULL, FALSE);
2433 file = g_file_new_for_uri (uri);
2434 result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_shortcut_folder (chooser, file, error);
2435 g_object_unref (file);
2441 * gtk_file_chooser_list_shortcut_folder_uris:
2442 * @chooser: a #GtkFileChooser
2444 * Queries the list of shortcut folders in the file chooser, as set by
2445 * gtk_file_chooser_add_shortcut_folder_uri().
2447 * Return value: (element-type utf8) (transfer full): A list of folder URIs, or %NULL if there are no shortcut
2448 * folders. Free the returned list with g_slist_free(), and the URIs with
2454 gtk_file_chooser_list_shortcut_folder_uris (GtkFileChooser *chooser)
2459 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2461 folders = _gtk_file_chooser_list_shortcut_folder_files (chooser);
2463 result = files_to_strings (folders, g_file_get_uri);
2464 g_slist_foreach (folders, (GFunc) g_object_unref, NULL);
2465 g_slist_free (folders);
2471 _gtk_file_chooser_list_shortcut_folder_files (GtkFileChooser *chooser)
2473 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2475 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->list_shortcut_folders (chooser);
2479 * gtk_file_chooser_set_show_hidden:
2480 * @chooser: a #GtkFileChooser
2481 * @show_hidden: %TRUE if hidden files and folders should be displayed.
2483 * Sets whether hidden files and folders are displayed in the file selector.
2488 gtk_file_chooser_set_show_hidden (GtkFileChooser *chooser,
2489 gboolean show_hidden)
2491 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
2493 g_object_set (chooser, "show-hidden", show_hidden, NULL);
2497 * gtk_file_chooser_get_show_hidden:
2498 * @chooser: a #GtkFileChooser
2500 * Gets whether hidden files and folders are displayed in the file selector.
2501 * See gtk_file_chooser_set_show_hidden().
2503 * Return value: %TRUE if hidden files and folders are displayed.
2508 gtk_file_chooser_get_show_hidden (GtkFileChooser *chooser)
2510 gboolean show_hidden;
2512 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2514 g_object_get (chooser, "show-hidden", &show_hidden, NULL);
2520 * gtk_file_chooser_set_do_overwrite_confirmation:
2521 * @chooser: a #GtkFileChooser
2522 * @do_overwrite_confirmation: whether to confirm overwriting in save mode
2524 * Sets whether a file chooser in %GTK_FILE_CHOOSER_ACTION_SAVE mode will present
2525 * a confirmation dialog if the user types a file name that already exists. This
2526 * is %FALSE by default.
2528 * Regardless of this setting, the @chooser will emit the
2529 * #GtkFileChooser::confirm-overwrite signal when appropriate.
2531 * If all you need is the stock confirmation dialog, set this property to %TRUE.
2532 * You can override the way confirmation is done by actually handling the
2533 * #GtkFileChooser::confirm-overwrite signal; please refer to its documentation
2539 gtk_file_chooser_set_do_overwrite_confirmation (GtkFileChooser *chooser,
2540 gboolean do_overwrite_confirmation)
2542 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
2544 g_object_set (chooser, "do-overwrite-confirmation", do_overwrite_confirmation, NULL);
2548 * gtk_file_chooser_get_do_overwrite_confirmation:
2549 * @chooser: a #GtkFileChooser
2551 * Queries whether a file chooser is set to confirm for overwriting when the user
2552 * types a file name that already exists.
2554 * Return value: %TRUE if the file chooser will present a confirmation dialog;
2560 gtk_file_chooser_get_do_overwrite_confirmation (GtkFileChooser *chooser)
2562 gboolean do_overwrite_confirmation;
2564 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2566 g_object_get (chooser, "do-overwrite-confirmation", &do_overwrite_confirmation, NULL);
2568 return do_overwrite_confirmation;