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, see <http://www.gnu.org/licenses/>.
20 #include "gtkfilechooser.h"
21 #include "gtkfilechooserprivate.h"
23 #include "gtktypebuiltins.h"
24 #include "gtkprivate.h"
25 #include "gtkmarshalers.h"
29 * SECTION:gtkfilechooser
30 * @Short_description: File chooser interface used by GtkFileChooserWidget and GtkFileChooserDialog
31 * @Title: GtkFileChooser
32 * @See_also: #GtkFileChooserDialog, #GtkFileChooserWidget, #GtkFileChooserButton
34 * #GtkFileChooser is an interface that can be implemented by file
35 * selection widgets. In GTK+, the main objects that implement this
36 * interface are #GtkFileChooserWidget, #GtkFileChooserDialog, and
37 * #GtkFileChooserButton. You do not need to write an object that
38 * implements the #GtkFileChooser interface unless you are trying to
39 * adapt an existing file selector to expose a standard programming
42 * #GtkFileChooser allows for shortcuts to various places in the filesystem.
43 * In the default implementation these are displayed in the left pane. It
44 * may be a bit confusing at first that these shortcuts come from various
45 * sources and in various flavours, so lets explain the terminology here:
48 * <term>Bookmarks</term>
50 * are created by the user, by dragging folders from the
51 * right pane to the left pane, or by using the "Add". Bookmarks
52 * can be renamed and deleted by the user.
56 * <term>Shortcuts</term>
58 * can be provided by the application or by the underlying filesystem
59 * abstraction (e.g. both the gnome-vfs and the Windows filesystems
60 * provide "Desktop" shortcuts). Shortcuts cannot be modified by the
65 * <term>Volumes</term>
67 * are provided by the underlying filesystem abstraction. They are
68 * the "roots" of the filesystem.
73 * <refsect2 id="gtkfilechooser-encodings">
74 * <title>File Names and Encodings</title>
75 * When the user is finished selecting files in a
76 * #GtkFileChooser, your program can get the selected names
77 * either as filenames or as URIs. For URIs, the normal escaping
78 * rules are applied if the URI contains non-ASCII characters.
79 * However, filenames are <emphasis>always</emphasis> returned in
80 * the character set specified by the
81 * <envar>G_FILENAME_ENCODING</envar> environment variable.
82 * Please see the GLib documentation for more details about this
85 * This means that while you can pass the result of
86 * gtk_file_chooser_get_filename() to
87 * <function>open(2)</function> or
88 * <function>fopen(3)</function>, you may not be able to
89 * directly set it as the text of a #GtkLabel widget unless you
90 * convert it first to UTF-8, which all GTK+ widgets expect.
91 * You should use g_filename_to_utf8() to convert filenames
92 * into strings that can be passed to GTK+ widgets.
95 * <refsect2 id="gtkfilechooser-preview">
96 * <title>Adding a Preview Widget</title>
98 * You can add a custom preview widget to a file chooser and then
99 * get notification about when the preview needs to be updated.
100 * To install a preview widget, use
101 * gtk_file_chooser_set_preview_widget(). Then, connect to the
102 * #GtkFileChooser::update-preview signal to get notified when
103 * you need to update the contents of the preview.
106 * Your callback should use
107 * gtk_file_chooser_get_preview_filename() to see what needs
108 * previewing. Once you have generated the preview for the
109 * corresponding file, you must call
110 * gtk_file_chooser_set_preview_widget_active() with a boolean
111 * flag that indicates whether your callback could successfully
112 * generate a preview.
114 * <example id="example-gtkfilechooser-preview">
115 * <title>Sample Usage</title>
122 * preview = gtk_image_new (<!-- -->);
124 * gtk_file_chooser_set_preview_widget (my_file_chooser, preview);
125 * g_signal_connect (my_file_chooser, "update-preview",
126 * G_CALLBACK (update_preview_cb), preview);
130 * update_preview_cb (GtkFileChooser *file_chooser, gpointer data)
132 * GtkWidget *preview;
135 * gboolean have_preview;
137 * preview = GTK_WIDGET (data);
138 * filename = gtk_file_chooser_get_preview_filename (file_chooser);
140 * pixbuf = gdk_pixbuf_new_from_file_at_size (filename, 128, 128, NULL);
141 * have_preview = (pixbuf != NULL);
144 * gtk_image_set_from_pixbuf (GTK_IMAGE (preview), pixbuf);
146 * g_object_unref (pixbuf);
148 * gtk_file_chooser_set_preview_widget_active (file_chooser, have_preview);
153 * <refsect2 id="gtkfilechooser-extra">
154 * <title>Adding Extra Widgets</title>
156 * You can add extra widgets to a file chooser to provide options
157 * that are not present in the default design. For example, you
158 * can add a toggle button to give the user the option to open a
159 * file in read-only mode. You can use
160 * gtk_file_chooser_set_extra_widget() to insert additional
161 * widgets in a file chooser.
163 * <example id="example-gtkfilechooser-extra">
164 * <title>Sample Usage</title>
171 * toggle = gtk_check_button_new_with_label ("Open file read-only");
172 * gtk_widget_show (toggle);
173 * gtk_file_chooser_set_extra_widget (my_file_chooser, toggle);
178 * If you want to set more than one extra widget in the file
179 * chooser, you can a container such as a #GtkBox or a #GtkGrid
180 * and include your widgets in it. Then, set the container as
181 * the whole extra widget.
184 * <refsect2 id="gtkfilechooser-key-bindings">
185 * <title>Key Bindings</title>
187 * Internally, GTK+ implements a file chooser's graphical user
188 * interface with the private
189 * <classname>GtkFileChooserDefaultClass</classname>. This
190 * widget has several <link linkend="gtk-Bindings">key
191 * bindings</link> and their associated signals. This section
192 * describes the available key binding signals.
194 * <example id="gtkfilechooser-key-binding-example">
195 * <title>GtkFileChooser key binding example</title>
197 * The default keys that activate the key-binding signals in
198 * <classname>GtkFileChooserDefaultClass</classname> are as
205 * <entry>Signal name</entry>
206 * <entry>Default key combinations</entry>
209 * <entry>location-popup</entry>
211 * <keycombo><keycap>Control</keycap><keycap>L</keycap></keycombo> (empty path);
212 * <keycap>/</keycap> (path of "/")
214 * Both the individual <keycap>/</keycap> key and the
215 * numeric keypad's "divide" key are supported.
217 * <keycap>~</keycap> (path of "~")
221 * <entry>up-folder</entry>
223 * <keycombo><keycap>Alt</keycap><keycap>Up</keycap></keycombo>;
224 * <keycombo><keycap>Alt</keycap><keycap>Shift</keycap><keycap>Up</keycap></keycombo>
226 * Both the individual Up key and the numeric
227 * keypad's Up key are supported.
229 * <keycap>Backspace</keycap>
233 * <entry>down-folder</entry>
235 * <keycombo><keycap>Alt</keycap><keycap>Down</keycap></keycombo>;
236 * <keycombo><keycap>Alt</keycap><keycap>Shift</keycap><keycap>Down</keycap></keycombo>
238 * Both the individual Down key and the numeric
239 * keypad's Down key are supported.
244 * <entry>home-folder</entry>
245 * <entry><keycombo><keycap>Alt</keycap><keycap>Home</keycap></keycombo></entry>
248 * <entry>desktop-folder</entry>
249 * <entry><keycombo><keycap>Alt</keycap><keycap>D</keycap></keycombo></entry>
252 * <entry>quick-bookmark</entry>
253 * <entry><keycombo><keycap>Alt</keycap><keycap>1</keycap></keycombo> through <keycombo><keycap>Alt</keycap><keycap>0</keycap></keycombo></entry>
259 * You can change these defaults to something else. For
260 * example, to add a <keycap>Shift</keycap> modifier to a few
261 * of the default bindings, you can include the following
262 * fragment in your <filename>.config/gtk-3.0/gtk.css</filename> file:
265 * @binding-set MyOwnFilechooserBindings
267 * bind "<Alt><Shift>Up" { "up-folder" () }
268 * bind "<Alt><Shift>Down" { "down-folder" () }
269 * bind "<Alt><Shift>Home" { "home-folder" () }
272 * GtkFileChooserDefault
274 * gtk-key-bindings: MyOwnFilechooserBindings
278 * <refsect3 id="GtkFileChooserDefault-location-popup">
279 * <title>The "GtkFileChooserDefault::location-popup" signal</title>
281 * void user_function (GtkFileChooserDefault *chooser,
283 * <link linkend="gpointer">gpointer</link> user_data);
286 * This is used to make the file chooser show a "Location"
287 * dialog which the user can use to manually type the name of
288 * the file he wishes to select. The
289 * <parameter>path</parameter> argument is a string that gets
290 * put in the text entry for the file name. By default this is bound to
291 * <keycombo><keycap>Control</keycap><keycap>L</keycap></keycombo>
292 * with a <parameter>path</parameter> string of "" (the empty
293 * string). It is also bound to <keycap>/</keycap> with a
294 * <parameter>path</parameter> string of "<literal>/</literal>"
295 * (a slash): this lets you type <keycap>/</keycap> and
296 * immediately type a path name. On Unix systems, this is bound to
297 * <keycap>~</keycap> (tilde) with a <parameter>path</parameter> string
298 * of "~" itself for access to home directories.
300 * <variablelist role="params">
302 * <term><parameter>chooser</parameter> :</term>
305 * the object which received the signal.
310 * <term><parameter>path</parameter> :</term>
313 * default contents for the text entry for the file name
318 * <term><parameter>user_data</parameter> :</term>
321 * user data set when the signal handler was connected.
327 * You can create your own bindings for the
328 * #GtkFileChooserDefault::location-popup signal with custom
329 * <parameter>path</parameter> strings, and have a crude form
330 * of easily-to-type bookmarks. For example, say you access
331 * the path <filename>/home/username/misc</filename> very
332 * frequently. You could then create an <keycombo>
333 * <keycap>Alt</keycap> <keycap>M</keycap> </keycombo>
334 * shortcut by including the following in your
335 * <filename>.config/gtk-3.0/gtk.css</filename>:
337 * @binding-set MiscShortcut
339 * bind "<Alt>M" { "location-popup" ("/home/username/misc") }
342 * GtkFileChooserDefault
344 * gtk-key-bindings: MiscShortcut
349 * <refsect3 id="GtkFileChooserDefault-up-folder">
350 * <title>The "GtkFileChooserDefault::up-folder" signal</title>
352 * void user_function (GtkFileChooserDefault *chooser,
353 * <link linkend="gpointer">gpointer</link> user_data);
356 * This is used to make the file chooser go to the parent of
357 * the current folder in the file hierarchy. By default this
358 * is bound to <keycap>Backspace</keycap> and
359 * <keycombo><keycap>Alt</keycap><keycap>Up</keycap></keycombo>
360 * (the Up key in the numeric keypad also works).
362 * <variablelist role="params">
364 * <term><parameter>chooser</parameter> :</term>
367 * the object which received the signal.
372 * <term><parameter>user_data</parameter> :</term>
375 * user data set when the signal handler was connected.
381 * <refsect3 id="GtkFileChooserDefault-down-folder">
382 * <title>The "GtkFileChooserDefault::down-folder" signal</title>
384 * void user_function (GtkFileChooserDefault *chooser,
385 * <link linkend="gpointer">gpointer</link> user_data);
388 * This is used to make the file chooser go to a child of the
389 * current folder in the file hierarchy. The subfolder that
390 * will be used is displayed in the path bar widget of the file
391 * chooser. For example, if the path bar is showing
392 * "/foo/<emphasis>bar/</emphasis>baz", then this will cause
393 * the file chooser to switch to the "baz" subfolder. By
394 * default this is bound to
395 * <keycombo><keycap>Alt</keycap><keycap>Down</keycap></keycombo>
396 * (the Down key in the numeric keypad also works).
398 * <variablelist role="params">
400 * <term><parameter>chooser</parameter> :</term>
403 * the object which received the signal.
408 * <term><parameter>user_data</parameter> :</term>
411 * user data set when the signal handler was connected.
417 * <refsect3 id="GtkFileChooserDefault-home-folder">
418 * <title>The "GtkFileChooserDefault::home-folder" signal</title>
420 * void user_function (GtkFileChooserDefault *chooser,
421 * <link linkend="gpointer">gpointer</link> user_data);
424 * This is used to make the file chooser show the user's home
425 * folder in the file list. By default this is bound to
426 * <keycombo><keycap>Alt</keycap><keycap>Home</keycap></keycombo>
427 * (the Home key in the numeric keypad also works).
429 * <variablelist role="params">
431 * <term><parameter>chooser</parameter> :</term>
434 * the object which received the signal.
439 * <term><parameter>user_data</parameter> :</term>
442 * user data set when the signal handler was connected.
448 * <refsect3 id="GtkFileChooserDefault-desktop-folder">
449 * <title>The "GtkFileChooserDefault::desktop-folder" signal</title>
451 * void user_function (GtkFileChooserDefault *chooser,
452 * <link linkend="gpointer">gpointer</link> user_data);
455 * This is used to make the file chooser show the user's Desktop
456 * folder in the file list. By default this is bound to
457 * <keycombo><keycap>Alt</keycap><keycap>D</keycap></keycombo>.
459 * <variablelist role="params">
461 * <term><parameter>chooser</parameter> :</term>
464 * the object which received the signal.
469 * <term><parameter>user_data</parameter> :</term>
472 * user data set when the signal handler was connected.
478 * <refsect3 id="GtkFileChooserDefault-quick-bookmark">
479 * <title>The "GtkFileChooserDefault::quick-bookmark" signal</title>
481 * void user_function (GtkFileChooserDefault *chooser,
482 * gint bookmark_index,
483 * <link linkend="gpointer">gpointer</link> user_data);
486 * This is used to make the file chooser switch to the bookmark
487 * specified in the <parameter>bookmark_index</parameter> parameter.
488 * For example, if you have three bookmarks, you can pass 0, 1, 2 to
489 * this signal to switch to each of them, respectively. By default this is bound to
490 * <keycombo><keycap>Alt</keycap><keycap>1</keycap></keycombo>,
491 * <keycombo><keycap>Alt</keycap><keycap>2</keycap></keycombo>,
493 * <keycombo><keycap>Alt</keycap><keycap>0</keycap></keycombo>. Note
494 * that in the default binding,
495 * that <keycombo><keycap>Alt</keycap><keycap>1</keycap></keycombo> is
496 * actually defined to switch to the bookmark at index 0, and so on
498 * <keycombo><keycap>Alt</keycap><keycap>0</keycap></keycombo> is
499 * defined to switch to the bookmark at index 10.
501 * <variablelist role="params">
503 * <term><parameter>chooser</parameter> :</term>
506 * the object which received the signal.
511 * <term><parameter>bookmark_indes</parameter> :</term>
514 * index of the bookmark to switch to; the indices start at 0.
519 * <term><parameter>user_data</parameter> :</term>
522 * user data set when the signal handler was connected.
532 typedef GtkFileChooserIface GtkFileChooserInterface;
533 G_DEFINE_INTERFACE (GtkFileChooser, gtk_file_chooser, GTK_TYPE_WIDGET);
536 confirm_overwrite_accumulator (GSignalInvocationHint *ihint,
538 const GValue *handler_return,
541 gboolean continue_emission;
542 GtkFileChooserConfirmation conf;
544 conf = g_value_get_enum (handler_return);
545 g_value_set_enum (return_accu, conf);
546 continue_emission = (conf == GTK_FILE_CHOOSER_CONFIRMATION_CONFIRM);
548 return continue_emission;
552 gtk_file_chooser_default_init (GtkFileChooserInterface *iface)
554 GType iface_type = G_TYPE_FROM_INTERFACE (iface);
557 * GtkFileChooser::current-folder-changed:
558 * @chooser: the object which received the signal.
560 * This signal is emitted when the current folder in a #GtkFileChooser
561 * changes. This can happen due to the user performing some action that
562 * changes folders, such as selecting a bookmark or visiting a folder on the
563 * file list. It can also happen as a result of calling a function to
564 * explicitly change the current folder in a file chooser.
566 * Normally you do not need to connect to this signal, unless you need to keep
567 * track of which folder a file chooser is showing.
569 * See also: gtk_file_chooser_set_current_folder(),
570 * gtk_file_chooser_get_current_folder(),
571 * gtk_file_chooser_set_current_folder_uri(),
572 * gtk_file_chooser_get_current_folder_uri().
574 g_signal_new (I_("current-folder-changed"),
577 G_STRUCT_OFFSET (GtkFileChooserIface, current_folder_changed),
579 g_cclosure_marshal_VOID__VOID,
583 * GtkFileChooser::selection-changed:
584 * @chooser: the object which received the signal.
586 * This signal is emitted when there is a change in the set of selected files
587 * in a #GtkFileChooser. This can happen when the user modifies the selection
588 * with the mouse or the keyboard, or when explicitly calling functions to
589 * change the selection.
591 * Normally you do not need to connect to this signal, as it is easier to wait
592 * for the file chooser to finish running, and then to get the list of
593 * selected files using the functions mentioned below.
595 * See also: gtk_file_chooser_select_filename(),
596 * gtk_file_chooser_unselect_filename(), gtk_file_chooser_get_filename(),
597 * gtk_file_chooser_get_filenames(), gtk_file_chooser_select_uri(),
598 * gtk_file_chooser_unselect_uri(), gtk_file_chooser_get_uri(),
599 * gtk_file_chooser_get_uris().
601 g_signal_new (I_("selection-changed"),
604 G_STRUCT_OFFSET (GtkFileChooserIface, selection_changed),
606 g_cclosure_marshal_VOID__VOID,
610 * GtkFileChooser::update-preview:
611 * @chooser: the object which received the signal.
613 * This signal is emitted when the preview in a file chooser should be
614 * regenerated. For example, this can happen when the currently selected file
615 * changes. You should use this signal if you want your file chooser to have
618 * Once you have installed a preview widget with
619 * gtk_file_chooser_set_preview_widget(), you should update it when this
620 * signal is emitted. You can use the functions
621 * gtk_file_chooser_get_preview_filename() or
622 * gtk_file_chooser_get_preview_uri() to get the name of the file to preview.
623 * Your widget may not be able to preview all kinds of files; your callback
624 * must call gtk_file_chooser_set_preview_widget_active() to inform the file
625 * chooser about whether the preview was generated successfully or not.
627 * Please see the example code in <xref linkend="gtkfilechooser-preview"/>.
629 * See also: gtk_file_chooser_set_preview_widget(),
630 * gtk_file_chooser_set_preview_widget_active(),
631 * gtk_file_chooser_set_use_preview_label(),
632 * gtk_file_chooser_get_preview_filename(),
633 * gtk_file_chooser_get_preview_uri().
635 g_signal_new (I_("update-preview"),
638 G_STRUCT_OFFSET (GtkFileChooserIface, update_preview),
640 g_cclosure_marshal_VOID__VOID,
644 * GtkFileChooser::file-activated:
645 * @chooser: the object which received the signal.
647 * This signal is emitted when the user "activates" a file in the file
648 * chooser. This can happen by double-clicking on a file in the file list, or
649 * by pressing <keycap>Enter</keycap>.
651 * Normally you do not need to connect to this signal. It is used internally
652 * by #GtkFileChooserDialog to know when to activate the default button in the
655 * See also: gtk_file_chooser_get_filename(),
656 * gtk_file_chooser_get_filenames(), gtk_file_chooser_get_uri(),
657 * gtk_file_chooser_get_uris().
659 g_signal_new (I_("file-activated"),
662 G_STRUCT_OFFSET (GtkFileChooserIface, file_activated),
664 g_cclosure_marshal_VOID__VOID,
668 * GtkFileChooser::confirm-overwrite:
669 * @chooser: the object which received the signal.
671 * This signal gets emitted whenever it is appropriate to present a
672 * confirmation dialog when the user has selected a file name that
673 * already exists. The signal only gets emitted when the file
674 * chooser is in %GTK_FILE_CHOOSER_ACTION_SAVE mode.
676 * Most applications just need to turn on the
677 * #GtkFileChooser:do-overwrite-confirmation property (or call the
678 * gtk_file_chooser_set_do_overwrite_confirmation() function), and
679 * they will automatically get a stock confirmation dialog.
680 * Applications which need to customize this behavior should do
681 * that, and also connect to the #GtkFileChooser::confirm-overwrite
684 * A signal handler for this signal must return a
685 * #GtkFileChooserConfirmation value, which indicates the action to
686 * take. If the handler determines that the user wants to select a
687 * different filename, it should return
688 * %GTK_FILE_CHOOSER_CONFIRMATION_SELECT_AGAIN. If it determines
689 * that the user is satisfied with his choice of file name, it
690 * should return %GTK_FILE_CHOOSER_CONFIRMATION_ACCEPT_FILENAME.
691 * On the other hand, if it determines that the stock confirmation
692 * dialog should be used, it should return
693 * %GTK_FILE_CHOOSER_CONFIRMATION_CONFIRM. The following example
695 * <example id="gtkfilechooser-confirmation">
696 * <title>Custom confirmation</title>
698 * static GtkFileChooserConfirmation
699 * confirm_overwrite_callback (GtkFileChooser *chooser, gpointer data)
703 * uri = gtk_file_chooser_get_uri (chooser);
705 * if (is_uri_read_only (uri))
707 * if (user_wants_to_replace_read_only_file (uri))
708 * return GTK_FILE_CHOOSER_CONFIRMATION_ACCEPT_FILENAME;
710 * return GTK_FILE_CHOOSER_CONFIRMATION_SELECT_AGAIN;
712 * return GTK_FILE_CHOOSER_CONFIRMATION_CONFIRM; // fall back to the default dialog
717 * chooser = gtk_file_chooser_dialog_new (...);
719 * gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), TRUE);
720 * g_signal_connect (chooser, "confirm-overwrite",
721 * G_CALLBACK (confirm_overwrite_callback), NULL);
723 * if (gtk_dialog_run (chooser) == GTK_RESPONSE_ACCEPT)
724 * save_to_file (gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (chooser));
726 * gtk_widget_destroy (chooser);
730 * Returns: a #GtkFileChooserConfirmation value that indicates which
731 * action to take after emitting the signal.
735 g_signal_new (I_("confirm-overwrite"),
738 G_STRUCT_OFFSET (GtkFileChooserIface, confirm_overwrite),
739 confirm_overwrite_accumulator, NULL,
740 _gtk_marshal_ENUM__VOID,
741 GTK_TYPE_FILE_CHOOSER_CONFIRMATION, 0);
743 g_object_interface_install_property (iface,
744 g_param_spec_enum ("action",
746 P_("The type of operation that the file selector is performing"),
747 GTK_TYPE_FILE_CHOOSER_ACTION,
748 GTK_FILE_CHOOSER_ACTION_OPEN,
749 GTK_PARAM_READWRITE));
750 g_object_interface_install_property (iface,
751 g_param_spec_object ("filter",
753 P_("The current filter for selecting which files are displayed"),
754 GTK_TYPE_FILE_FILTER,
755 GTK_PARAM_READWRITE));
756 g_object_interface_install_property (iface,
757 g_param_spec_boolean ("local-only",
759 P_("Whether the selected file(s) should be limited to local file: URLs"),
761 GTK_PARAM_READWRITE));
762 g_object_interface_install_property (iface,
763 g_param_spec_object ("preview-widget",
764 P_("Preview widget"),
765 P_("Application supplied widget for custom previews."),
767 GTK_PARAM_READWRITE));
768 g_object_interface_install_property (iface,
769 g_param_spec_boolean ("preview-widget-active",
770 P_("Preview Widget Active"),
771 P_("Whether the application supplied widget for custom previews should be shown."),
773 GTK_PARAM_READWRITE));
774 g_object_interface_install_property (iface,
775 g_param_spec_boolean ("use-preview-label",
776 P_("Use Preview Label"),
777 P_("Whether to display a stock label with the name of the previewed file."),
779 GTK_PARAM_READWRITE));
780 g_object_interface_install_property (iface,
781 g_param_spec_object ("extra-widget",
783 P_("Application supplied widget for extra options."),
785 GTK_PARAM_READWRITE));
786 g_object_interface_install_property (iface,
787 g_param_spec_boolean ("select-multiple",
788 P_("Select Multiple"),
789 P_("Whether to allow multiple files to be selected"),
791 GTK_PARAM_READWRITE));
793 g_object_interface_install_property (iface,
794 g_param_spec_boolean ("show-hidden",
796 P_("Whether the hidden files and folders should be displayed"),
798 GTK_PARAM_READWRITE));
801 * GtkFileChooser:do-overwrite-confirmation:
803 * Whether a file chooser in %GTK_FILE_CHOOSER_ACTION_SAVE mode
804 * will present an overwrite confirmation dialog if the user
805 * selects a file name that already exists.
809 g_object_interface_install_property (iface,
810 g_param_spec_boolean ("do-overwrite-confirmation",
811 P_("Do overwrite confirmation"),
812 P_("Whether a file chooser in save mode "
813 "will present an overwrite confirmation dialog "
816 GTK_PARAM_READWRITE));
819 * GtkFileChooser:create-folders:
821 * Whether a file chooser not in %GTK_FILE_CHOOSER_ACTION_OPEN mode
822 * will offer the user to create new folders.
826 g_object_interface_install_property (iface,
827 g_param_spec_boolean ("create-folders",
828 P_("Allow folder creation"),
829 P_("Whether a file chooser not in open mode "
830 "will offer the user to create new folders."),
832 GTK_PARAM_READWRITE));
836 * gtk_file_chooser_error_quark:
838 * Registers an error quark for #GtkFileChooser if necessary.
840 * Return value: The error quark used for #GtkFileChooser errors.
845 gtk_file_chooser_error_quark (void)
847 return g_quark_from_static_string ("gtk-file-chooser-error-quark");
851 * gtk_file_chooser_set_action:
852 * @chooser: a #GtkFileChooser
853 * @action: the action that the file selector is performing
855 * Sets the type of operation that the chooser is performing; the
856 * user interface is adapted to suit the selected action. For example,
857 * an option to create a new folder might be shown if the action is
858 * %GTK_FILE_CHOOSER_ACTION_SAVE but not if the action is
859 * %GTK_FILE_CHOOSER_ACTION_OPEN.
864 gtk_file_chooser_set_action (GtkFileChooser *chooser,
865 GtkFileChooserAction action)
867 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
869 g_object_set (chooser, "action", action, NULL);
873 * gtk_file_chooser_get_action:
874 * @chooser: a #GtkFileChooser
876 * Gets the type of operation that the file chooser is performing; see
877 * gtk_file_chooser_set_action().
879 * Return value: the action that the file selector is performing
884 gtk_file_chooser_get_action (GtkFileChooser *chooser)
886 GtkFileChooserAction action;
888 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
890 g_object_get (chooser, "action", &action, NULL);
896 * gtk_file_chooser_set_local_only:
897 * @chooser: a #GtkFileChooser
898 * @local_only: %TRUE if only local files can be selected
900 * Sets whether only local files can be selected in the
901 * file selector. If @local_only is %TRUE (the default),
902 * then the selected file are files are guaranteed to be
903 * accessible through the operating systems native file
904 * file system and therefore the application only
905 * needs to worry about the filename functions in
906 * #GtkFileChooser, like gtk_file_chooser_get_filename(),
907 * rather than the URI functions like
908 * gtk_file_chooser_get_uri(),
910 * On some systems non-native files may still be
911 * available using the native filesystem via a userspace
917 gtk_file_chooser_set_local_only (GtkFileChooser *chooser,
920 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
922 g_object_set (chooser, "local-only", local_only, NULL);
926 * gtk_file_chooser_get_local_only:
927 * @chooser: a #GtkFileChooser
929 * Gets whether only local files can be selected in the
930 * file selector. See gtk_file_chooser_set_local_only()
932 * Return value: %TRUE if only local files can be selected.
937 gtk_file_chooser_get_local_only (GtkFileChooser *chooser)
941 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
943 g_object_get (chooser, "local-only", &local_only, NULL);
949 * gtk_file_chooser_set_select_multiple:
950 * @chooser: a #GtkFileChooser
951 * @select_multiple: %TRUE if multiple files can be selected.
953 * Sets whether multiple files can be selected in the file selector. This is
954 * only relevant if the action is set to be %GTK_FILE_CHOOSER_ACTION_OPEN or
955 * %GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER.
960 gtk_file_chooser_set_select_multiple (GtkFileChooser *chooser,
961 gboolean select_multiple)
963 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
965 g_object_set (chooser, "select-multiple", select_multiple, NULL);
969 * gtk_file_chooser_get_select_multiple:
970 * @chooser: a #GtkFileChooser
972 * Gets whether multiple files can be selected in the file
973 * selector. See gtk_file_chooser_set_select_multiple().
975 * Return value: %TRUE if multiple files can be selected.
980 gtk_file_chooser_get_select_multiple (GtkFileChooser *chooser)
982 gboolean select_multiple;
984 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
986 g_object_get (chooser, "select-multiple", &select_multiple, NULL);
988 return select_multiple;
992 * gtk_file_chooser_set_create_folders:
993 * @chooser: a #GtkFileChooser
994 * @create_folders: %TRUE if the New Folder button should be displayed
996 * Sets whether file choser will offer to create new folders.
997 * This is only relevant if the action is not set to be
998 * %GTK_FILE_CHOOSER_ACTION_OPEN.
1003 gtk_file_chooser_set_create_folders (GtkFileChooser *chooser,
1004 gboolean create_folders)
1006 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1008 g_object_set (chooser, "create-folders", create_folders, NULL);
1012 * gtk_file_chooser_get_create_folders:
1013 * @chooser: a #GtkFileChooser
1015 * Gets whether file choser will offer to create new folders.
1016 * See gtk_file_chooser_set_create_folders().
1018 * Return value: %TRUE if the New Folder button should be displayed.
1023 gtk_file_chooser_get_create_folders (GtkFileChooser *chooser)
1025 gboolean create_folders;
1027 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1029 g_object_get (chooser, "create-folders", &create_folders, NULL);
1031 return create_folders;
1035 * gtk_file_chooser_get_filename:
1036 * @chooser: a #GtkFileChooser
1038 * Gets the filename for the currently selected file in
1039 * the file selector. The filename is returned as an absolute path. If
1040 * multiple files are selected, one of the filenames will be returned at
1043 * If the file chooser is in folder mode, this function returns the selected
1046 * Return value: (type filename): The currently selected filename, or %NULL
1047 * if no file is selected, or the selected file can't
1048 * be represented with a local filename. Free with g_free().
1053 gtk_file_chooser_get_filename (GtkFileChooser *chooser)
1056 gchar *result = NULL;
1058 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1060 file = gtk_file_chooser_get_file (chooser);
1064 result = g_file_get_path (file);
1065 g_object_unref (file);
1072 * gtk_file_chooser_set_filename:
1073 * @chooser: a #GtkFileChooser
1074 * @filename: (type filename): the filename to set as current
1076 * Sets @filename as the current filename for the file chooser, by changing to
1077 * the file's parent folder and actually selecting the file in list; all other
1078 * files will be unselected. If the @chooser is in
1079 * %GTK_FILE_CHOOSER_ACTION_SAVE mode, the file's base name will also appear in
1080 * the dialog's file name entry.
1082 * Note that the file must exist, or nothing will be done except
1083 * for the directory change.
1085 * You should use this function only when implementing a <guimenuitem>File/Save
1086 * As...</guimenuitem> dialog for which you already have a file name to which
1087 * the user may save. For example, when the user opens an existing file and
1088 * then does <guimenuitem>File/Save As...</guimenuitem> on it to save a copy or
1089 * a modified version. If you don't have a file name already — for
1090 * example, if the user just created a new file and is saving it for the first
1091 * time, do not call this function. Instead, use something similar to this:
1093 * if (document_is_new)
1095 * /* the user just created a new document */
1096 * gtk_file_chooser_set_current_name (chooser, "Untitled document");
1100 * /* the user edited an existing document */
1101 * gtk_file_chooser_set_filename (chooser, existing_filename);
1105 * In the first case, the file chooser will present the user with useful suggestions
1106 * as to where to save his new file. In the second case, the file's existing location
1107 * is already known, so the file chooser will use it.
1109 * Return value: Not useful.
1114 gtk_file_chooser_set_filename (GtkFileChooser *chooser,
1115 const gchar *filename)
1117 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1119 gtk_file_chooser_unselect_all (chooser);
1120 return gtk_file_chooser_select_filename (chooser, filename);
1124 * gtk_file_chooser_select_filename:
1125 * @chooser: a #GtkFileChooser
1126 * @filename: (type filename): the filename to select
1128 * Selects a filename. If the file name isn't in the current
1129 * folder of @chooser, then the current folder of @chooser will
1130 * be changed to the folder containing @filename.
1132 * Return value: Not useful.
1134 * See also: gtk_file_chooser_set_filename()
1139 gtk_file_chooser_select_filename (GtkFileChooser *chooser,
1140 const gchar *filename)
1145 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1146 g_return_val_if_fail (filename != NULL, FALSE);
1148 file = g_file_new_for_path (filename);
1149 result = gtk_file_chooser_select_file (chooser, file, NULL);
1150 g_object_unref (file);
1156 * gtk_file_chooser_unselect_filename:
1157 * @chooser: a #GtkFileChooser
1158 * @filename: (type filename): the filename to unselect
1160 * Unselects a currently selected filename. If the filename
1161 * is not in the current directory, does not exist, or
1162 * is otherwise not currently selected, does nothing.
1167 gtk_file_chooser_unselect_filename (GtkFileChooser *chooser,
1168 const char *filename)
1172 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1173 g_return_if_fail (filename != NULL);
1175 file = g_file_new_for_path (filename);
1176 gtk_file_chooser_unselect_file (chooser, file);
1177 g_object_unref (file);
1180 /* Converts a list of GFile* to a list of strings using the specified function */
1182 files_to_strings (GSList *files,
1183 gchar * (*convert_func) (GFile *file))
1189 for (; files; files = files->next)
1195 string = (* convert_func) (file);
1198 strings = g_slist_prepend (strings, string);
1201 return g_slist_reverse (strings);
1205 * gtk_file_chooser_get_filenames:
1206 * @chooser: a #GtkFileChooser
1208 * Lists all the selected files and subfolders in the current folder of
1209 * @chooser. The returned names are full absolute paths. If files in the current
1210 * folder cannot be represented as local filenames they will be ignored. (See
1211 * gtk_file_chooser_get_uris())
1213 * Return value: (element-type filename) (transfer full): a #GSList
1214 * containing the filenames of all selected files and subfolders in
1215 * the current folder. Free the returned list with g_slist_free(),
1216 * and the filenames with g_free().
1221 gtk_file_chooser_get_filenames (GtkFileChooser *chooser)
1223 GSList *files, *result;
1225 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1227 files = gtk_file_chooser_get_files (chooser);
1229 result = files_to_strings (files, g_file_get_path);
1230 g_slist_foreach (files, (GFunc) g_object_unref, NULL);
1231 g_slist_free (files);
1237 * gtk_file_chooser_set_current_folder:
1238 * @chooser: a #GtkFileChooser
1239 * @filename: (type filename): the full path of the new current folder
1241 * Sets the current folder for @chooser from a local filename.
1242 * The user will be shown the full contents of the current folder,
1243 * plus user interface elements for navigating to other folders.
1245 * In general, you should not use this function. See the <link
1246 * linkend="gtkfilechooserdialog-setting-up">section on setting up a file
1247 * chooser dialog</link> for the rationale behind this.
1249 * Return value: Not useful.
1254 gtk_file_chooser_set_current_folder (GtkFileChooser *chooser,
1255 const gchar *filename)
1260 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1261 g_return_val_if_fail (filename != NULL, FALSE);
1263 file = g_file_new_for_path (filename);
1264 result = gtk_file_chooser_set_current_folder_file (chooser, file, NULL);
1265 g_object_unref (file);
1271 * gtk_file_chooser_get_current_folder:
1272 * @chooser: a #GtkFileChooser
1274 * Gets the current folder of @chooser as a local filename.
1275 * See gtk_file_chooser_set_current_folder().
1277 * Note that this is the folder that the file chooser is currently displaying
1278 * (e.g. "/home/username/Documents"), which is <emphasis>not the same</emphasis>
1279 * as the currently-selected folder if the chooser is in
1280 * %GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER mode
1281 * (e.g. "/home/username/Documents/selected-folder/". To get the
1282 * currently-selected folder in that mode, use gtk_file_chooser_get_uri() as the
1283 * usual way to get the selection.
1285 * Return value: (type filename): the full path of the current folder,
1286 * or %NULL if the current path cannot be represented as a local
1287 * filename. Free with g_free(). This function will also return
1288 * %NULL if the file chooser was unable to load the last folder that
1289 * was requested from it; for example, as would be for calling
1290 * gtk_file_chooser_set_current_folder() on a nonexistent folder.
1295 gtk_file_chooser_get_current_folder (GtkFileChooser *chooser)
1300 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1302 file = gtk_file_chooser_get_current_folder_file (chooser);
1306 filename = g_file_get_path (file);
1307 g_object_unref (file);
1313 * gtk_file_chooser_set_current_name:
1314 * @chooser: a #GtkFileChooser
1315 * @name: (type filename): the filename to use, as a UTF-8 string
1317 * Sets the current name in the file selector, as if entered
1318 * by the user. Note that the name passed in here is a UTF-8
1319 * string rather than a filename. This function is meant for
1320 * such uses as a suggested name in a "Save As..." dialog. You can
1321 * pass "Untitled.doc" or a similarly suitable suggestion for the @name.
1323 * If you want to preselect a particular existing file, you should use
1324 * gtk_file_chooser_set_filename() or gtk_file_chooser_set_uri() instead.
1325 * Please see the documentation for those functions for an example of using
1326 * gtk_file_chooser_set_current_name() as well.
1331 gtk_file_chooser_set_current_name (GtkFileChooser *chooser,
1334 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1335 g_return_if_fail (name != NULL);
1337 GTK_FILE_CHOOSER_GET_IFACE (chooser)->set_current_name (chooser, name);
1341 * gtk_file_chooser_get_uri:
1342 * @chooser: a #GtkFileChooser
1344 * Gets the URI for the currently selected file in
1345 * the file selector. If multiple files are selected,
1346 * one of the filenames will be returned at random.
1348 * If the file chooser is in folder mode, this function returns the selected
1351 * Return value: The currently selected URI, or %NULL
1352 * if no file is selected. If gtk_file_chooser_set_local_only() is set to %TRUE
1353 * (the default) a local URI will be returned for any FUSE locations.
1354 * Free with g_free()
1359 gtk_file_chooser_get_uri (GtkFileChooser *chooser)
1362 gchar *result = NULL;
1364 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1366 file = gtk_file_chooser_get_file (chooser);
1369 if (gtk_file_chooser_get_local_only (chooser))
1371 gchar *local = g_file_get_path (file);
1374 result = g_filename_to_uri (local, NULL, NULL);
1380 result = g_file_get_uri (file);
1382 g_object_unref (file);
1389 * gtk_file_chooser_set_uri:
1390 * @chooser: a #GtkFileChooser
1391 * @uri: the URI to set as current
1393 * Sets the file referred to by @uri as the current file for the file chooser,
1394 * by changing to the URI's parent folder and actually selecting the URI in the
1395 * list. If the @chooser is %GTK_FILE_CHOOSER_ACTION_SAVE mode, the URI's base
1396 * name will also appear in the dialog's file name entry.
1398 * Note that the URI must exist, or nothing will be done except for the
1401 * You should use this function only when implementing a <guimenuitem>File/Save
1402 * As...</guimenuitem> dialog for which you already have a file name to which
1403 * the user may save. For example, whenthe user opens an existing file and then
1404 * does <guimenuitem>File/Save As...</guimenuitem> on it to save a copy or a
1405 * modified version. If you don't have a file name already — for example,
1406 * if the user just created a new file and is saving it for the first time, do
1407 * not call this function. Instead, use something similar to this:
1409 * if (document_is_new)
1411 * /* the user just created a new document */
1412 * gtk_file_chooser_set_current_name (chooser, "Untitled document");
1416 * /* the user edited an existing document */
1417 * gtk_file_chooser_set_uri (chooser, existing_uri);
1422 * In the first case, the file chooser will present the user with useful suggestions
1423 * as to where to save his new file. In the second case, the file's existing location
1424 * is already known, so the file chooser will use it.
1426 * Return value: Not useful.
1431 gtk_file_chooser_set_uri (GtkFileChooser *chooser,
1434 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1436 gtk_file_chooser_unselect_all (chooser);
1437 return gtk_file_chooser_select_uri (chooser, uri);
1441 * gtk_file_chooser_select_uri:
1442 * @chooser: a #GtkFileChooser
1443 * @uri: the URI to select
1445 * Selects the file to by @uri. If the URI doesn't refer to a
1446 * file in the current folder of @chooser, then the current folder of
1447 * @chooser will be changed to the folder containing @filename.
1449 * Return value: Not useful.
1454 gtk_file_chooser_select_uri (GtkFileChooser *chooser,
1460 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1461 g_return_val_if_fail (uri != NULL, FALSE);
1463 file = g_file_new_for_uri (uri);
1464 result = gtk_file_chooser_select_file (chooser, file, NULL);
1465 g_object_unref (file);
1471 * gtk_file_chooser_unselect_uri:
1472 * @chooser: a #GtkFileChooser
1473 * @uri: the URI to unselect
1475 * Unselects the file referred to by @uri. If the file
1476 * is not in the current directory, does not exist, or
1477 * is otherwise not currently selected, does nothing.
1482 gtk_file_chooser_unselect_uri (GtkFileChooser *chooser,
1487 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1488 g_return_if_fail (uri != NULL);
1490 file = g_file_new_for_uri (uri);
1491 gtk_file_chooser_unselect_file (chooser, file);
1492 g_object_unref (file);
1496 * gtk_file_chooser_select_all:
1497 * @chooser: a #GtkFileChooser
1499 * Selects all the files in the current folder of a file chooser.
1504 gtk_file_chooser_select_all (GtkFileChooser *chooser)
1506 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1508 GTK_FILE_CHOOSER_GET_IFACE (chooser)->select_all (chooser);
1512 * gtk_file_chooser_unselect_all:
1513 * @chooser: a #GtkFileChooser
1515 * Unselects all the files in the current folder of a file chooser.
1520 gtk_file_chooser_unselect_all (GtkFileChooser *chooser)
1523 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1525 GTK_FILE_CHOOSER_GET_IFACE (chooser)->unselect_all (chooser);
1529 * gtk_file_chooser_get_uris:
1530 * @chooser: a #GtkFileChooser
1532 * Lists all the selected files and subfolders in the current folder of
1533 * @chooser. The returned names are full absolute URIs.
1535 * Return value: (element-type utf8) (transfer full): a #GSList containing the URIs of all selected
1536 * files and subfolders in the current folder. Free the returned list
1537 * with g_slist_free(), and the filenames with g_free().
1542 gtk_file_chooser_get_uris (GtkFileChooser *chooser)
1544 GSList *files, *result;
1546 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1548 files = gtk_file_chooser_get_files (chooser);
1550 result = files_to_strings (files, g_file_get_uri);
1551 g_slist_foreach (files, (GFunc) g_object_unref, NULL);
1552 g_slist_free (files);
1558 * gtk_file_chooser_set_current_folder_uri:
1559 * @chooser: a #GtkFileChooser
1560 * @uri: the URI for the new current folder
1562 * Sets the current folder for @chooser from an URI.
1563 * The user will be shown the full contents of the current folder,
1564 * plus user interface elements for navigating to other folders.
1566 * In general, you should not use this function. See the <link
1567 * linkend="gtkfilechooserdialog-setting-up">section on setting up a file
1568 * chooser dialog</link> for the rationale behind this.
1570 * Return value: %TRUE if the folder could be changed successfully, %FALSE
1576 gtk_file_chooser_set_current_folder_uri (GtkFileChooser *chooser,
1582 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1583 g_return_val_if_fail (uri != NULL, FALSE);
1585 file = g_file_new_for_uri (uri);
1586 result = gtk_file_chooser_set_current_folder_file (chooser, file, NULL);
1587 g_object_unref (file);
1593 * gtk_file_chooser_get_current_folder_uri:
1594 * @chooser: a #GtkFileChooser
1596 * Gets the current folder of @chooser as an URI.
1597 * See gtk_file_chooser_set_current_folder_uri().
1599 * Note that this is the folder that the file chooser is currently displaying
1600 * (e.g. "file:///home/username/Documents"), which is <emphasis>not the same</emphasis>
1601 * as the currently-selected folder if the chooser is in
1602 * %GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER mode
1603 * (e.g. "file:///home/username/Documents/selected-folder/". To get the
1604 * currently-selected folder in that mode, use gtk_file_chooser_get_uri() as the
1605 * usual way to get the selection.
1607 * Return value: the URI for the current folder. Free with g_free(). This
1608 * function will also return %NULL if the file chooser was unable to load the
1609 * last folder that was requested from it; for example, as would be for calling
1610 * gtk_file_chooser_set_current_folder_uri() on a nonexistent folder.
1615 gtk_file_chooser_get_current_folder_uri (GtkFileChooser *chooser)
1620 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1622 file = gtk_file_chooser_get_current_folder_file (chooser);
1626 uri = g_file_get_uri (file);
1627 g_object_unref (file);
1633 * gtk_file_chooser_set_current_folder_file:
1634 * @chooser: a #GtkFileChooser
1635 * @file: the #GFile for the new folder
1636 * @error: (allow-none): location to store error, or %NULL.
1638 * Sets the current folder for @chooser from a #GFile.
1639 * Internal function, see gtk_file_chooser_set_current_folder_uri().
1641 * Return value: %TRUE if the folder could be changed successfully, %FALSE
1647 gtk_file_chooser_set_current_folder_file (GtkFileChooser *chooser,
1651 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1652 g_return_val_if_fail (G_IS_FILE (file), FALSE);
1653 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
1655 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->set_current_folder (chooser, file, error);
1659 * gtk_file_chooser_get_current_folder_file:
1660 * @chooser: a #GtkFileChooser
1662 * Gets the current folder of @chooser as #GFile.
1663 * See gtk_file_chooser_get_current_folder_uri().
1665 * Return value: (transfer full): the #GFile for the current folder.
1670 gtk_file_chooser_get_current_folder_file (GtkFileChooser *chooser)
1672 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1674 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_current_folder (chooser);
1678 * gtk_file_chooser_select_file:
1679 * @chooser: a #GtkFileChooser
1680 * @file: the file to select
1681 * @error: (allow-none): location to store error, or %NULL
1683 * Selects the file referred to by @file. An internal function. See
1684 * _gtk_file_chooser_select_uri().
1686 * Return value: Not useful.
1691 gtk_file_chooser_select_file (GtkFileChooser *chooser,
1695 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1696 g_return_val_if_fail (G_IS_FILE (file), FALSE);
1697 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
1699 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->select_file (chooser, file, error);
1703 * gtk_file_chooser_unselect_file:
1704 * @chooser: a #GtkFileChooser
1707 * Unselects the file referred to by @file. If the file is not in the current
1708 * directory, does not exist, or is otherwise not currently selected, does nothing.
1713 gtk_file_chooser_unselect_file (GtkFileChooser *chooser,
1716 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1717 g_return_if_fail (G_IS_FILE (file));
1719 GTK_FILE_CHOOSER_GET_IFACE (chooser)->unselect_file (chooser, file);
1723 * gtk_file_chooser_get_files:
1724 * @chooser: a #GtkFileChooser
1726 * Lists all the selected files and subfolders in the current folder of @chooser
1727 * as #GFile. An internal function, see gtk_file_chooser_get_uris().
1729 * Return value: (element-type GFile) (transfer full): a #GSList
1730 * containing a #GFile for each selected file and subfolder in the
1731 * current folder. Free the returned list with g_slist_free(), and
1732 * the files with g_object_unref().
1737 gtk_file_chooser_get_files (GtkFileChooser *chooser)
1739 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1741 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_files (chooser);
1745 * gtk_file_chooser_set_file:
1746 * @chooser: a #GtkFileChooser
1747 * @file: the #GFile to set as current
1748 * @error: (allow-none): location to store the error, or %NULL to ignore errors.
1750 * Sets @file as the current filename for the file chooser, by changing
1751 * to the file's parent folder and actually selecting the file in list. If
1752 * the @chooser is in %GTK_FILE_CHOOSER_ACTION_SAVE mode, the file's base name
1753 * will also appear in the dialog's file name entry.
1755 * If the file name isn't in the current folder of @chooser, then the current
1756 * folder of @chooser will be changed to the folder containing @filename. This
1757 * is equivalent to a sequence of gtk_file_chooser_unselect_all() followed by
1758 * gtk_file_chooser_select_filename().
1760 * Note that the file must exist, or nothing will be done except
1761 * for the directory change.
1763 * If you are implementing a <guimenuitem>File/Save As...</guimenuitem> dialog,
1764 * you should use this function if you already have a file name to which the
1765 * user may save; for example, when the user opens an existing file and then
1766 * does <guimenuitem>File/Save As...</guimenuitem> on it. If you don't have
1767 * a file name already — for example, if the user just created a new
1768 * file and is saving it for the first time, do not call this function.
1769 * Instead, use something similar to this:
1771 * if (document_is_new)
1773 * /* the user just created a new document */
1774 * gtk_file_chooser_set_current_folder_file (chooser, default_file_for_saving);
1775 * gtk_file_chooser_set_current_name (chooser, "Untitled document");
1779 * /* the user edited an existing document */
1780 * gtk_file_chooser_set_file (chooser, existing_file);
1784 * Return value: Not useful.
1789 gtk_file_chooser_set_file (GtkFileChooser *chooser,
1793 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1794 g_return_val_if_fail (G_IS_FILE (file), FALSE);
1795 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
1797 gtk_file_chooser_unselect_all (chooser);
1798 return gtk_file_chooser_select_file (chooser, file, error);
1802 * gtk_file_chooser_get_file:
1803 * @chooser: a #GtkFileChooser
1805 * Gets the #GFile for the currently selected file in
1806 * the file selector. If multiple files are selected,
1807 * one of the files will be returned at random.
1809 * If the file chooser is in folder mode, this function returns the selected
1812 * Returns: (transfer full): a selected #GFile. You own the returned file;
1813 * use g_object_unref() to release it.
1818 gtk_file_chooser_get_file (GtkFileChooser *chooser)
1821 GFile *result = NULL;
1823 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1825 list = gtk_file_chooser_get_files (chooser);
1828 result = list->data;
1829 list = g_slist_delete_link (list, list);
1831 g_slist_foreach (list, (GFunc) g_object_unref, NULL);
1832 g_slist_free (list);
1839 * _gtk_file_chooser_get_file_system:
1840 * @chooser: a #GtkFileChooser
1842 * Gets the #GtkFileSystem of @chooser; this is an internal
1843 * implementation detail, used for conversion between paths
1844 * and filenames and URIs.
1846 * Return value: the file system for @chooser.
1851 _gtk_file_chooser_get_file_system (GtkFileChooser *chooser)
1853 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1855 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_file_system (chooser);
1861 * gtk_file_chooser_set_preview_widget:
1862 * @chooser: a #GtkFileChooser
1863 * @preview_widget: widget for displaying preview.
1865 * Sets an application-supplied widget to use to display a custom preview
1866 * of the currently selected file. To implement a preview, after setting the
1867 * preview widget, you connect to the #GtkFileChooser::update-preview
1868 * signal, and call gtk_file_chooser_get_preview_filename() or
1869 * gtk_file_chooser_get_preview_uri() on each change. If you can
1870 * display a preview of the new file, update your widget and
1871 * set the preview active using gtk_file_chooser_set_preview_widget_active().
1872 * Otherwise, set the preview inactive.
1874 * When there is no application-supplied preview widget, or the
1875 * application-supplied preview widget is not active, the file chooser
1876 * may display an internally generated preview of the current file or
1877 * it may display no preview at all.
1882 gtk_file_chooser_set_preview_widget (GtkFileChooser *chooser,
1883 GtkWidget *preview_widget)
1885 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1887 g_object_set (chooser, "preview-widget", preview_widget, NULL);
1891 * gtk_file_chooser_get_preview_widget:
1892 * @chooser: a #GtkFileChooser
1894 * Gets the current preview widget; see
1895 * gtk_file_chooser_set_preview_widget().
1897 * Return value: (transfer none): the current preview widget, or %NULL
1902 gtk_file_chooser_get_preview_widget (GtkFileChooser *chooser)
1904 GtkWidget *preview_widget;
1906 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1908 g_object_get (chooser, "preview-widget", &preview_widget, NULL);
1910 /* Horrid hack; g_object_get() refs returned objects but
1911 * that contradicts the memory management conventions
1915 g_object_unref (preview_widget);
1917 return preview_widget;
1921 * gtk_file_chooser_set_preview_widget_active:
1922 * @chooser: a #GtkFileChooser
1923 * @active: whether to display the user-specified preview widget
1925 * Sets whether the preview widget set by
1926 * gtk_file_chooser_set_preview_widget() should be shown for the
1927 * current filename. When @active is set to false, the file chooser
1928 * may display an internally generated preview of the current file
1929 * or it may display no preview at all. See
1930 * gtk_file_chooser_set_preview_widget() for more details.
1935 gtk_file_chooser_set_preview_widget_active (GtkFileChooser *chooser,
1938 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1940 g_object_set (chooser, "preview-widget-active", active, NULL);
1944 * gtk_file_chooser_get_preview_widget_active:
1945 * @chooser: a #GtkFileChooser
1947 * Gets whether the preview widget set by gtk_file_chooser_set_preview_widget()
1948 * should be shown for the current filename. See
1949 * gtk_file_chooser_set_preview_widget_active().
1951 * Return value: %TRUE if the preview widget is active for the current filename.
1956 gtk_file_chooser_get_preview_widget_active (GtkFileChooser *chooser)
1960 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1962 g_object_get (chooser, "preview-widget-active", &active, NULL);
1968 * gtk_file_chooser_set_use_preview_label:
1969 * @chooser: a #GtkFileChooser
1970 * @use_label: whether to display a stock label with the name of the previewed file
1972 * Sets whether the file chooser should display a stock label with the name of
1973 * the file that is being previewed; the default is %TRUE. Applications that
1974 * want to draw the whole preview area themselves should set this to %FALSE and
1975 * display the name themselves in their preview widget.
1977 * See also: gtk_file_chooser_set_preview_widget()
1982 gtk_file_chooser_set_use_preview_label (GtkFileChooser *chooser,
1985 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1987 g_object_set (chooser, "use-preview-label", use_label, NULL);
1991 * gtk_file_chooser_get_use_preview_label:
1992 * @chooser: a #GtkFileChooser
1994 * Gets whether a stock label should be drawn with the name of the previewed
1995 * file. See gtk_file_chooser_set_use_preview_label().
1997 * Return value: %TRUE if the file chooser is set to display a label with the
1998 * name of the previewed file, %FALSE otherwise.
2001 gtk_file_chooser_get_use_preview_label (GtkFileChooser *chooser)
2005 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2007 g_object_get (chooser, "use-preview-label", &use_label, NULL);
2013 * gtk_file_chooser_get_preview_file:
2014 * @chooser: a #GtkFileChooser
2016 * Gets the #GFile that should be previewed in a custom preview
2017 * Internal function, see gtk_file_chooser_get_preview_uri().
2019 * Return value: (transfer full): the #GFile for the file to preview,
2020 * or %NULL if no file is selected. Free with g_object_unref().
2025 gtk_file_chooser_get_preview_file (GtkFileChooser *chooser)
2027 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2029 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_preview_file (chooser);
2033 * _gtk_file_chooser_add_shortcut_folder:
2034 * @chooser: a #GtkFileChooser
2035 * @file: file for the folder to add
2036 * @error: (allow-none): location to store error, or %NULL
2038 * Adds a folder to be displayed with the shortcut folders in a file chooser.
2039 * Internal function, see gtk_file_chooser_add_shortcut_folder().
2041 * Return value: %TRUE if the folder could be added successfully, %FALSE
2047 _gtk_file_chooser_add_shortcut_folder (GtkFileChooser *chooser,
2051 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2052 g_return_val_if_fail (G_IS_FILE (file), FALSE);
2054 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_shortcut_folder (chooser, file, error);
2058 * _gtk_file_chooser_remove_shortcut_folder:
2059 * @chooser: a #GtkFileChooser
2060 * @file: file for the folder to remove
2061 * @error: (allow-none): location to store error, or %NULL
2063 * Removes a folder from the shortcut folders in a file chooser. Internal
2064 * function, see gtk_file_chooser_remove_shortcut_folder().
2066 * Return value: %TRUE if the folder could be removed successfully, %FALSE
2072 _gtk_file_chooser_remove_shortcut_folder (GtkFileChooser *chooser,
2076 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2077 g_return_val_if_fail (G_IS_FILE (file), FALSE);
2079 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_shortcut_folder (chooser, file, error);
2083 * gtk_file_chooser_get_preview_filename:
2084 * @chooser: a #GtkFileChooser
2086 * Gets the filename that should be previewed in a custom preview
2087 * widget. See gtk_file_chooser_set_preview_widget().
2089 * Return value: (type filename): the filename to preview, or %NULL if
2090 * no file is selected, or if the selected file cannot be represented
2091 * as a local filename. Free with g_free()
2096 gtk_file_chooser_get_preview_filename (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_path (file);
2107 g_object_unref (file);
2114 * gtk_file_chooser_get_preview_uri:
2115 * @chooser: a #GtkFileChooser
2117 * Gets the URI that should be previewed in a custom preview
2118 * widget. See gtk_file_chooser_set_preview_widget().
2120 * Return value: the URI for the file to preview, or %NULL if no file is
2121 * selected. Free with g_free().
2126 gtk_file_chooser_get_preview_uri (GtkFileChooser *chooser)
2129 gchar *result = NULL;
2131 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2133 file = gtk_file_chooser_get_preview_file (chooser);
2136 result = g_file_get_uri (file);
2137 g_object_unref (file);
2144 * gtk_file_chooser_set_extra_widget:
2145 * @chooser: a #GtkFileChooser
2146 * @extra_widget: widget for extra options
2148 * Sets an application-supplied widget to provide extra options to the user.
2153 gtk_file_chooser_set_extra_widget (GtkFileChooser *chooser,
2154 GtkWidget *extra_widget)
2156 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
2158 g_object_set (chooser, "extra-widget", extra_widget, NULL);
2162 * gtk_file_chooser_get_extra_widget:
2163 * @chooser: a #GtkFileChooser
2165 * Gets the current preview widget; see
2166 * gtk_file_chooser_set_extra_widget().
2168 * Return value: (transfer none): the current extra widget, or %NULL
2173 gtk_file_chooser_get_extra_widget (GtkFileChooser *chooser)
2175 GtkWidget *extra_widget;
2177 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2179 g_object_get (chooser, "extra-widget", &extra_widget, NULL);
2181 /* Horrid hack; g_object_get() refs returned objects but
2182 * that contradicts the memory management conventions
2186 g_object_unref (extra_widget);
2188 return extra_widget;
2192 * gtk_file_chooser_add_filter:
2193 * @chooser: a #GtkFileChooser
2194 * @filter: a #GtkFileFilter
2196 * Adds @filter to the list of filters that the user can select between.
2197 * When a filter is selected, only files that are passed by that
2198 * filter are displayed.
2200 * Note that the @chooser takes ownership of the filter, so you have to
2201 * ref and sink it if you want to keep a reference.
2206 gtk_file_chooser_add_filter (GtkFileChooser *chooser,
2207 GtkFileFilter *filter)
2209 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
2211 GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_filter (chooser, filter);
2215 * gtk_file_chooser_remove_filter:
2216 * @chooser: a #GtkFileChooser
2217 * @filter: a #GtkFileFilter
2219 * Removes @filter from the list of filters that the user can select between.
2224 gtk_file_chooser_remove_filter (GtkFileChooser *chooser,
2225 GtkFileFilter *filter)
2227 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
2229 GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_filter (chooser, filter);
2233 * gtk_file_chooser_list_filters:
2234 * @chooser: a #GtkFileChooser
2236 * Lists the current set of user-selectable filters; see
2237 * gtk_file_chooser_add_filter(), gtk_file_chooser_remove_filter().
2239 * Return value: (element-type GtkFileFilter) (transfer container): a
2240 * #GSList containing the current set of user selectable filters. The
2241 * contents of the list are owned by GTK+, but you must free the list
2242 * itself with g_slist_free() when you are done with it.
2247 gtk_file_chooser_list_filters (GtkFileChooser *chooser)
2249 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2251 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->list_filters (chooser);
2255 * gtk_file_chooser_set_filter:
2256 * @chooser: a #GtkFileChooser
2257 * @filter: a #GtkFileFilter
2259 * Sets the current filter; only the files that pass the
2260 * filter will be displayed. If the user-selectable list of filters
2261 * is non-empty, then the filter should be one of the filters
2262 * in that list. Setting the current filter when the list of
2263 * filters is empty is useful if you want to restrict the displayed
2264 * set of files without letting the user change it.
2269 gtk_file_chooser_set_filter (GtkFileChooser *chooser,
2270 GtkFileFilter *filter)
2272 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
2273 g_return_if_fail (GTK_IS_FILE_FILTER (filter));
2275 g_object_set (chooser, "filter", filter, NULL);
2279 * gtk_file_chooser_get_filter:
2280 * @chooser: a #GtkFileChooser
2282 * Gets the current filter; see gtk_file_chooser_set_filter().
2284 * Return value: (transfer none): the current filter, or %NULL
2289 gtk_file_chooser_get_filter (GtkFileChooser *chooser)
2291 GtkFileFilter *filter;
2293 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2295 g_object_get (chooser, "filter", &filter, NULL);
2296 /* Horrid hack; g_object_get() refs returned objects but
2297 * that contradicts the memory management conventions
2301 g_object_unref (filter);
2307 * gtk_file_chooser_add_shortcut_folder:
2308 * @chooser: a #GtkFileChooser
2309 * @folder: (type filename): filename of the folder to add
2310 * @error: (allow-none): location to store error, or %NULL
2312 * Adds a folder to be displayed with the shortcut folders in a file chooser.
2313 * Note that shortcut folders do not get saved, as they are provided by the
2314 * application. For example, you can use this to add a
2315 * "/usr/share/mydrawprogram/Clipart" folder to the volume list.
2317 * Return value: %TRUE if the folder could be added successfully, %FALSE
2318 * otherwise. In the latter case, the @error will be set as appropriate.
2323 gtk_file_chooser_add_shortcut_folder (GtkFileChooser *chooser,
2330 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2331 g_return_val_if_fail (folder != NULL, FALSE);
2333 file = g_file_new_for_path (folder);
2334 result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_shortcut_folder (chooser, file, error);
2335 g_object_unref (file);
2341 * gtk_file_chooser_remove_shortcut_folder:
2342 * @chooser: a #GtkFileChooser
2343 * @folder: (type filename): filename of the folder to remove
2344 * @error: (allow-none): location to store error, or %NULL
2346 * Removes a folder from a file chooser's list of shortcut folders.
2348 * Return value: %TRUE if the operation succeeds, %FALSE otherwise.
2349 * In the latter case, the @error will be set as appropriate.
2351 * See also: gtk_file_chooser_add_shortcut_folder()
2356 gtk_file_chooser_remove_shortcut_folder (GtkFileChooser *chooser,
2363 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2364 g_return_val_if_fail (folder != NULL, FALSE);
2366 file = g_file_new_for_path (folder);
2367 result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_shortcut_folder (chooser, file, error);
2368 g_object_unref (file);
2374 * gtk_file_chooser_list_shortcut_folders:
2375 * @chooser: a #GtkFileChooser
2377 * Queries the list of shortcut folders in the file chooser, as set by
2378 * gtk_file_chooser_add_shortcut_folder().
2380 * Return value: (element-type filename) (transfer full): A list of
2381 * folder filenames, or %NULL if there are no shortcut folders. Free
2382 * the returned list with g_slist_free(), and the filenames with
2388 gtk_file_chooser_list_shortcut_folders (GtkFileChooser *chooser)
2393 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2395 folders = _gtk_file_chooser_list_shortcut_folder_files (chooser);
2397 result = files_to_strings (folders, g_file_get_path);
2398 g_slist_foreach (folders, (GFunc) g_object_unref, NULL);
2399 g_slist_free (folders);
2405 * gtk_file_chooser_add_shortcut_folder_uri:
2406 * @chooser: a #GtkFileChooser
2407 * @uri: URI of the folder to add
2408 * @error: (allow-none): location to store error, or %NULL
2410 * Adds a folder URI to be displayed with the shortcut folders in a file
2411 * chooser. Note that shortcut folders do not get saved, as they are provided
2412 * by the application. For example, you can use this to add a
2413 * "file:///usr/share/mydrawprogram/Clipart" folder to the volume list.
2415 * Return value: %TRUE if the folder could be added successfully, %FALSE
2416 * otherwise. In the latter case, the @error will be set as appropriate.
2421 gtk_file_chooser_add_shortcut_folder_uri (GtkFileChooser *chooser,
2428 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2429 g_return_val_if_fail (uri != NULL, FALSE);
2431 file = g_file_new_for_uri (uri);
2432 result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_shortcut_folder (chooser, file, error);
2433 g_object_unref (file);
2439 * gtk_file_chooser_remove_shortcut_folder_uri:
2440 * @chooser: a #GtkFileChooser
2441 * @uri: URI of the folder to remove
2442 * @error: (allow-none): location to store error, or %NULL
2444 * Removes a folder URI from a file chooser's list of shortcut folders.
2446 * Return value: %TRUE if the operation succeeds, %FALSE otherwise.
2447 * In the latter case, the @error will be set as appropriate.
2449 * See also: gtk_file_chooser_add_shortcut_folder_uri()
2454 gtk_file_chooser_remove_shortcut_folder_uri (GtkFileChooser *chooser,
2461 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2462 g_return_val_if_fail (uri != NULL, FALSE);
2464 file = g_file_new_for_uri (uri);
2465 result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_shortcut_folder (chooser, file, error);
2466 g_object_unref (file);
2472 * gtk_file_chooser_list_shortcut_folder_uris:
2473 * @chooser: a #GtkFileChooser
2475 * Queries the list of shortcut folders in the file chooser, as set by
2476 * gtk_file_chooser_add_shortcut_folder_uri().
2478 * Return value: (element-type utf8) (transfer full): A list of folder
2479 * URIs, or %NULL if there are no shortcut folders. Free the returned
2480 * list with g_slist_free(), and the URIs with g_free().
2485 gtk_file_chooser_list_shortcut_folder_uris (GtkFileChooser *chooser)
2490 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2492 folders = _gtk_file_chooser_list_shortcut_folder_files (chooser);
2494 result = files_to_strings (folders, g_file_get_uri);
2495 g_slist_foreach (folders, (GFunc) g_object_unref, NULL);
2496 g_slist_free (folders);
2502 _gtk_file_chooser_list_shortcut_folder_files (GtkFileChooser *chooser)
2504 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2506 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->list_shortcut_folders (chooser);
2510 * gtk_file_chooser_set_show_hidden:
2511 * @chooser: a #GtkFileChooser
2512 * @show_hidden: %TRUE if hidden files and folders should be displayed.
2514 * Sets whether hidden files and folders are displayed in the file selector.
2519 gtk_file_chooser_set_show_hidden (GtkFileChooser *chooser,
2520 gboolean show_hidden)
2522 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
2524 g_object_set (chooser, "show-hidden", show_hidden, NULL);
2528 * gtk_file_chooser_get_show_hidden:
2529 * @chooser: a #GtkFileChooser
2531 * Gets whether hidden files and folders are displayed in the file selector.
2532 * See gtk_file_chooser_set_show_hidden().
2534 * Return value: %TRUE if hidden files and folders are displayed.
2539 gtk_file_chooser_get_show_hidden (GtkFileChooser *chooser)
2541 gboolean show_hidden;
2543 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2545 g_object_get (chooser, "show-hidden", &show_hidden, NULL);
2551 * gtk_file_chooser_set_do_overwrite_confirmation:
2552 * @chooser: a #GtkFileChooser
2553 * @do_overwrite_confirmation: whether to confirm overwriting in save mode
2555 * Sets whether a file chooser in %GTK_FILE_CHOOSER_ACTION_SAVE mode will present
2556 * a confirmation dialog if the user types a file name that already exists. This
2557 * is %FALSE by default.
2559 * Regardless of this setting, the @chooser will emit the
2560 * #GtkFileChooser::confirm-overwrite signal when appropriate.
2562 * If all you need is the stock confirmation dialog, set this property to %TRUE.
2563 * You can override the way confirmation is done by actually handling the
2564 * #GtkFileChooser::confirm-overwrite signal; please refer to its documentation
2570 gtk_file_chooser_set_do_overwrite_confirmation (GtkFileChooser *chooser,
2571 gboolean do_overwrite_confirmation)
2573 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
2575 g_object_set (chooser, "do-overwrite-confirmation", do_overwrite_confirmation, NULL);
2579 * gtk_file_chooser_get_do_overwrite_confirmation:
2580 * @chooser: a #GtkFileChooser
2582 * Queries whether a file chooser is set to confirm for overwriting when the user
2583 * types a file name that already exists.
2585 * Return value: %TRUE if the file chooser will present a confirmation dialog;
2591 gtk_file_chooser_get_do_overwrite_confirmation (GtkFileChooser *chooser)
2593 gboolean do_overwrite_confirmation;
2595 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2597 g_object_get (chooser, "do-overwrite-confirmation", &do_overwrite_confirmation, NULL);
2599 return do_overwrite_confirmation;