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>;
226 * <keycombo><keycap>Alt</keycap><keycap>Shift</keycap><keycap>Up</keycap></keycombo>
228 * Both the individual Up key and the numeric
229 * keypad's Up key are supported.
231 * <keycap>Backspace</keycap>
235 * <entry>down-folder</entry>
237 * <keycombo><keycap>Alt</keycap><keycap>Down</keycap></keycombo>;
238 * <keycombo><keycap>Alt</keycap><keycap>Shift</keycap><keycap>Down</keycap></keycombo>
240 * Both the individual Down key and the numeric
241 * keypad's Down key are supported.
246 * <entry>home-folder</entry>
247 * <entry><keycombo><keycap>Alt</keycap><keycap>Home</keycap></keycombo></entry>
250 * <entry>desktop-folder</entry>
251 * <entry><keycombo><keycap>Alt</keycap><keycap>D</keycap></keycombo></entry>
254 * <entry>quick-bookmark</entry>
255 * <entry><keycombo><keycap>Alt</keycap><keycap>1</keycap></keycombo> through <keycombo><keycap>Alt</keycap><keycap>0</keycap></keycombo></entry>
261 * You can change these defaults to something else. For
262 * example, to add a <keycap>Shift</keycap> modifier to a few
263 * of the default bindings, you can include the following
264 * fragment in your <filename>.config/gtk-3.0/gtk.css</filename> file:
267 * @binding-set MyOwnFilechooserBindings
269 * bind "<Alt><Shift>Up" { "up-folder" () }
270 * bind "<Alt><Shift>Down" { "down-folder" () }
271 * bind "<Alt><Shift>Home" { "home-folder" () }
274 * GtkFileChooserDefault
276 * gtk-key-bindings: MyOwnFilechooserBindings
280 * <refsect3 id="GtkFileChooserDefault-location-popup">
281 * <title>The "GtkFileChooserDefault::location-popup" signal</title>
283 * void user_function (GtkFileChooserDefault *chooser,
285 * <link linkend="gpointer">gpointer</link> user_data);
288 * This is used to make the file chooser show a "Location"
289 * dialog which the user can use to manually type the name of
290 * the file he wishes to select. The
291 * <parameter>path</parameter> argument is a string that gets
292 * put in the text entry for the file name. By default this is bound to
293 * <keycombo><keycap>Control</keycap><keycap>L</keycap></keycombo>
294 * with a <parameter>path</parameter> string of "" (the empty
295 * string). It is also bound to <keycap>/</keycap> with a
296 * <parameter>path</parameter> string of "<literal>/</literal>"
297 * (a slash): this lets you type <keycap>/</keycap> and
298 * immediately type a path name. On Unix systems, this is bound to
299 * <keycap>~</keycap> (tilde) with a <parameter>path</parameter> string
300 * of "~" itself for access to home directories.
302 * <variablelist role="params">
304 * <term><parameter>chooser</parameter> :</term>
307 * the object which received the signal.
312 * <term><parameter>path</parameter> :</term>
315 * default contents for the text entry for the file name
320 * <term><parameter>user_data</parameter> :</term>
323 * user data set when the signal handler was connected.
329 * You can create your own bindings for the
330 * #GtkFileChooserDefault::location-popup signal with custom
331 * <parameter>path</parameter> strings, and have a crude form
332 * of easily-to-type bookmarks. For example, say you access
333 * the path <filename>/home/username/misc</filename> very
334 * frequently. You could then create an <keycombo>
335 * <keycap>Alt</keycap> <keycap>M</keycap> </keycombo>
336 * shortcut by including the following in your
337 * <filename>.config/gtk-3.0/gtk.css</filename>:
339 * @binding-set MiscShortcut
341 * bind "<Alt>M" { "location-popup" ("/home/username/misc") }
344 * GtkFileChooserDefault
346 * gtk-key-bindings: MiscShortcut
351 * <refsect3 id="GtkFileChooserDefault-up-folder">
352 * <title>The "GtkFileChooserDefault::up-folder" signal</title>
354 * void user_function (GtkFileChooserDefault *chooser,
355 * <link linkend="gpointer">gpointer</link> user_data);
358 * This is used to make the file chooser go to the parent of
359 * the current folder in the file hierarchy. By default this
360 * is bound to <keycap>Backspace</keycap> and
361 * <keycombo><keycap>Alt</keycap><keycap>Up</keycap></keycombo>
362 * (the Up key in the numeric keypad also works).
364 * <variablelist role="params">
366 * <term><parameter>chooser</parameter> :</term>
369 * the object which received the signal.
374 * <term><parameter>user_data</parameter> :</term>
377 * user data set when the signal handler was connected.
383 * <refsect3 id="GtkFileChooserDefault-down-folder">
384 * <title>The "GtkFileChooserDefault::down-folder" signal</title>
386 * void user_function (GtkFileChooserDefault *chooser,
387 * <link linkend="gpointer">gpointer</link> user_data);
390 * This is used to make the file chooser go to a child of the
391 * current folder in the file hierarchy. The subfolder that
392 * will be used is displayed in the path bar widget of the file
393 * chooser. For example, if the path bar is showing
394 * "/foo/<emphasis>bar/</emphasis>baz", then this will cause
395 * the file chooser to switch to the "baz" subfolder. By
396 * default this is bound to
397 * <keycombo><keycap>Alt</keycap><keycap>Down</keycap></keycombo>
398 * (the Down key in the numeric keypad also works).
400 * <variablelist role="params">
402 * <term><parameter>chooser</parameter> :</term>
405 * the object which received the signal.
410 * <term><parameter>user_data</parameter> :</term>
413 * user data set when the signal handler was connected.
419 * <refsect3 id="GtkFileChooserDefault-home-folder">
420 * <title>The "GtkFileChooserDefault::home-folder" signal</title>
422 * void user_function (GtkFileChooserDefault *chooser,
423 * <link linkend="gpointer">gpointer</link> user_data);
426 * This is used to make the file chooser show the user's home
427 * folder in the file list. By default this is bound to
428 * <keycombo><keycap>Alt</keycap><keycap>Home</keycap></keycombo>
429 * (the Home key in the numeric keypad also works).
431 * <variablelist role="params">
433 * <term><parameter>chooser</parameter> :</term>
436 * the object which received the signal.
441 * <term><parameter>user_data</parameter> :</term>
444 * user data set when the signal handler was connected.
450 * <refsect3 id="GtkFileChooserDefault-desktop-folder">
451 * <title>The "GtkFileChooserDefault::desktop-folder" signal</title>
453 * void user_function (GtkFileChooserDefault *chooser,
454 * <link linkend="gpointer">gpointer</link> user_data);
457 * This is used to make the file chooser show the user's Desktop
458 * folder in the file list. By default this is bound to
459 * <keycombo><keycap>Alt</keycap><keycap>D</keycap></keycombo>.
461 * <variablelist role="params">
463 * <term><parameter>chooser</parameter> :</term>
466 * the object which received the signal.
471 * <term><parameter>user_data</parameter> :</term>
474 * user data set when the signal handler was connected.
480 * <refsect3 id="GtkFileChooserDefault-quick-bookmark">
481 * <title>The "GtkFileChooserDefault::quick-bookmark" signal</title>
483 * void user_function (GtkFileChooserDefault *chooser,
484 * gint bookmark_index,
485 * <link linkend="gpointer">gpointer</link> user_data);
488 * This is used to make the file chooser switch to the bookmark
489 * specified in the <parameter>bookmark_index</parameter> parameter.
490 * For example, if you have three bookmarks, you can pass 0, 1, 2 to
491 * this signal to switch to each of them, respectively. By default this is bound to
492 * <keycombo><keycap>Alt</keycap><keycap>1</keycap></keycombo>,
493 * <keycombo><keycap>Alt</keycap><keycap>2</keycap></keycombo>,
495 * <keycombo><keycap>Alt</keycap><keycap>0</keycap></keycombo>. Note
496 * that in the default binding,
497 * that <keycombo><keycap>Alt</keycap><keycap>1</keycap></keycombo> is
498 * actually defined to switch to the bookmark at index 0, and so on
500 * <keycombo><keycap>Alt</keycap><keycap>0</keycap></keycombo> is
501 * defined to switch to the bookmark at index 10.
503 * <variablelist role="params">
505 * <term><parameter>chooser</parameter> :</term>
508 * the object which received the signal.
513 * <term><parameter>bookmark_indes</parameter> :</term>
516 * index of the bookmark to switch to; the indices start at 0.
521 * <term><parameter>user_data</parameter> :</term>
524 * user data set when the signal handler was connected.
534 typedef GtkFileChooserIface GtkFileChooserInterface;
535 G_DEFINE_INTERFACE (GtkFileChooser, gtk_file_chooser, GTK_TYPE_WIDGET);
538 confirm_overwrite_accumulator (GSignalInvocationHint *ihint,
540 const GValue *handler_return,
543 gboolean continue_emission;
544 GtkFileChooserConfirmation conf;
546 conf = g_value_get_enum (handler_return);
547 g_value_set_enum (return_accu, conf);
548 continue_emission = (conf == GTK_FILE_CHOOSER_CONFIRMATION_CONFIRM);
550 return continue_emission;
554 gtk_file_chooser_default_init (GtkFileChooserInterface *iface)
556 GType iface_type = G_TYPE_FROM_INTERFACE (iface);
559 * GtkFileChooser::current-folder-changed
560 * @chooser: the object which received the signal.
562 * This signal is emitted when the current folder in a #GtkFileChooser
563 * changes. This can happen due to the user performing some action that
564 * changes folders, such as selecting a bookmark or visiting a folder on the
565 * file list. It can also happen as a result of calling a function to
566 * explicitly change the current folder in a file chooser.
568 * Normally you do not need to connect to this signal, unless you need to keep
569 * track of which folder a file chooser is showing.
571 * See also: gtk_file_chooser_set_current_folder(),
572 * gtk_file_chooser_get_current_folder(),
573 * gtk_file_chooser_set_current_folder_uri(),
574 * gtk_file_chooser_get_current_folder_uri().
576 g_signal_new (I_("current-folder-changed"),
579 G_STRUCT_OFFSET (GtkFileChooserIface, current_folder_changed),
581 g_cclosure_marshal_VOID__VOID,
585 * GtkFileChooser::selection-changed
586 * @chooser: the object which received the signal.
588 * This signal is emitted when there is a change in the set of selected files
589 * in a #GtkFileChooser. This can happen when the user modifies the selection
590 * with the mouse or the keyboard, or when explicitly calling functions to
591 * change the selection.
593 * Normally you do not need to connect to this signal, as it is easier to wait
594 * for the file chooser to finish running, and then to get the list of
595 * selected files using the functions mentioned below.
597 * See also: gtk_file_chooser_select_filename(),
598 * gtk_file_chooser_unselect_filename(), gtk_file_chooser_get_filename(),
599 * gtk_file_chooser_get_filenames(), gtk_file_chooser_select_uri(),
600 * gtk_file_chooser_unselect_uri(), gtk_file_chooser_get_uri(),
601 * gtk_file_chooser_get_uris().
603 g_signal_new (I_("selection-changed"),
606 G_STRUCT_OFFSET (GtkFileChooserIface, selection_changed),
608 g_cclosure_marshal_VOID__VOID,
612 * GtkFileChooser::update-preview
613 * @chooser: the object which received the signal.
615 * This signal is emitted when the preview in a file chooser should be
616 * regenerated. For example, this can happen when the currently selected file
617 * changes. You should use this signal if you want your file chooser to have
620 * Once you have installed a preview widget with
621 * gtk_file_chooser_set_preview_widget(), you should update it when this
622 * signal is emitted. You can use the functions
623 * gtk_file_chooser_get_preview_filename() or
624 * gtk_file_chooser_get_preview_uri() to get the name of the file to preview.
625 * Your widget may not be able to preview all kinds of files; your callback
626 * must call gtk_file_chooser_set_preview_widget_active() to inform the file
627 * chooser about whether the preview was generated successfully or not.
629 * Please see the example code in <xref linkend="gtkfilechooser-preview"/>.
631 * See also: gtk_file_chooser_set_preview_widget(),
632 * gtk_file_chooser_set_preview_widget_active(),
633 * gtk_file_chooser_set_use_preview_label(),
634 * gtk_file_chooser_get_preview_filename(),
635 * gtk_file_chooser_get_preview_uri().
637 g_signal_new (I_("update-preview"),
640 G_STRUCT_OFFSET (GtkFileChooserIface, update_preview),
642 g_cclosure_marshal_VOID__VOID,
646 * GtkFileChooser::file-activated
647 * @chooser: the object which received the signal.
649 * This signal is emitted when the user "activates" a file in the file
650 * chooser. This can happen by double-clicking on a file in the file list, or
651 * by pressing <keycap>Enter</keycap>.
653 * Normally you do not need to connect to this signal. It is used internally
654 * by #GtkFileChooserDialog to know when to activate the default button in the
657 * See also: gtk_file_chooser_get_filename(),
658 * gtk_file_chooser_get_filenames(), gtk_file_chooser_get_uri(),
659 * gtk_file_chooser_get_uris().
661 g_signal_new (I_("file-activated"),
664 G_STRUCT_OFFSET (GtkFileChooserIface, file_activated),
666 g_cclosure_marshal_VOID__VOID,
670 * GtkFileChooser::confirm-overwrite:
671 * @chooser: the object which received the signal.
673 * This signal gets emitted whenever it is appropriate to present a
674 * confirmation dialog when the user has selected a file name that
675 * already exists. The signal only gets emitted when the file
676 * chooser is in %GTK_FILE_CHOOSER_ACTION_SAVE mode.
678 * Most applications just need to turn on the
679 * #GtkFileChooser:do-overwrite-confirmation property (or call the
680 * gtk_file_chooser_set_do_overwrite_confirmation() function), and
681 * they will automatically get a stock confirmation dialog.
682 * Applications which need to customize this behavior should do
683 * that, and also connect to the #GtkFileChooser::confirm-overwrite
686 * A signal handler for this signal must return a
687 * #GtkFileChooserConfirmation value, which indicates the action to
688 * take. If the handler determines that the user wants to select a
689 * different filename, it should return
690 * %GTK_FILE_CHOOSER_CONFIRMATION_SELECT_AGAIN. If it determines
691 * that the user is satisfied with his choice of file name, it
692 * should return %GTK_FILE_CHOOSER_CONFIRMATION_ACCEPT_FILENAME.
693 * On the other hand, if it determines that the stock confirmation
694 * dialog should be used, it should return
695 * %GTK_FILE_CHOOSER_CONFIRMATION_CONFIRM. The following example
697 * <example id="gtkfilechooser-confirmation">
698 * <title>Custom confirmation</title>
700 * static GtkFileChooserConfirmation
701 * confirm_overwrite_callback (GtkFileChooser *chooser, gpointer data)
705 * uri = gtk_file_chooser_get_uri (chooser);
707 * if (is_uri_read_only (uri))
709 * if (user_wants_to_replace_read_only_file (uri))
710 * return GTK_FILE_CHOOSER_CONFIRMATION_ACCEPT_FILENAME;
712 * return GTK_FILE_CHOOSER_CONFIRMATION_SELECT_AGAIN;
714 * return GTK_FILE_CHOOSER_CONFIRMATION_CONFIRM; // fall back to the default dialog
719 * chooser = gtk_file_chooser_dialog_new (...);
721 * gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), TRUE);
722 * g_signal_connect (chooser, "confirm-overwrite",
723 * G_CALLBACK (confirm_overwrite_callback), NULL);
725 * if (gtk_dialog_run (chooser) == GTK_RESPONSE_ACCEPT)
726 * save_to_file (gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (chooser));
728 * gtk_widget_destroy (chooser);
732 * Returns: a #GtkFileChooserConfirmation value that indicates which
733 * action to take after emitting the signal.
737 g_signal_new (I_("confirm-overwrite"),
740 G_STRUCT_OFFSET (GtkFileChooserIface, confirm_overwrite),
741 confirm_overwrite_accumulator, NULL,
742 _gtk_marshal_ENUM__VOID,
743 GTK_TYPE_FILE_CHOOSER_CONFIRMATION, 0);
745 g_object_interface_install_property (iface,
746 g_param_spec_enum ("action",
748 P_("The type of operation that the file selector is performing"),
749 GTK_TYPE_FILE_CHOOSER_ACTION,
750 GTK_FILE_CHOOSER_ACTION_OPEN,
751 GTK_PARAM_READWRITE));
752 g_object_interface_install_property (iface,
753 g_param_spec_object ("filter",
755 P_("The current filter for selecting which files are displayed"),
756 GTK_TYPE_FILE_FILTER,
757 GTK_PARAM_READWRITE));
758 g_object_interface_install_property (iface,
759 g_param_spec_boolean ("local-only",
761 P_("Whether the selected file(s) should be limited to local file: URLs"),
763 GTK_PARAM_READWRITE));
764 g_object_interface_install_property (iface,
765 g_param_spec_object ("preview-widget",
766 P_("Preview widget"),
767 P_("Application supplied widget for custom previews."),
769 GTK_PARAM_READWRITE));
770 g_object_interface_install_property (iface,
771 g_param_spec_boolean ("preview-widget-active",
772 P_("Preview Widget Active"),
773 P_("Whether the application supplied widget for custom previews should be shown."),
775 GTK_PARAM_READWRITE));
776 g_object_interface_install_property (iface,
777 g_param_spec_boolean ("use-preview-label",
778 P_("Use Preview Label"),
779 P_("Whether to display a stock label with the name of the previewed file."),
781 GTK_PARAM_READWRITE));
782 g_object_interface_install_property (iface,
783 g_param_spec_object ("extra-widget",
785 P_("Application supplied widget for extra options."),
787 GTK_PARAM_READWRITE));
788 g_object_interface_install_property (iface,
789 g_param_spec_boolean ("select-multiple",
790 P_("Select Multiple"),
791 P_("Whether to allow multiple files to be selected"),
793 GTK_PARAM_READWRITE));
795 g_object_interface_install_property (iface,
796 g_param_spec_boolean ("show-hidden",
798 P_("Whether the hidden files and folders should be displayed"),
800 GTK_PARAM_READWRITE));
803 * GtkFileChooser:do-overwrite-confirmation:
805 * Whether a file chooser in %GTK_FILE_CHOOSER_ACTION_SAVE mode
806 * will present an overwrite confirmation dialog if the user
807 * selects a file name that already exists.
811 g_object_interface_install_property (iface,
812 g_param_spec_boolean ("do-overwrite-confirmation",
813 P_("Do overwrite confirmation"),
814 P_("Whether a file chooser in save mode "
815 "will present an overwrite confirmation dialog "
818 GTK_PARAM_READWRITE));
821 * GtkFileChooser:create-folders:
823 * Whether a file chooser not in %GTK_FILE_CHOOSER_ACTION_OPEN mode
824 * will offer the user to create new folders.
828 g_object_interface_install_property (iface,
829 g_param_spec_boolean ("create-folders",
830 P_("Allow folder creation"),
831 P_("Whether a file chooser not in open mode "
832 "will offer the user to create new folders."),
834 GTK_PARAM_READWRITE));
838 * gtk_file_chooser_error_quark:
840 * Registers an error quark for #GtkFileChooser if necessary.
842 * Return value: The error quark used for #GtkFileChooser errors.
847 gtk_file_chooser_error_quark (void)
849 return g_quark_from_static_string ("gtk-file-chooser-error-quark");
853 * gtk_file_chooser_set_action:
854 * @chooser: a #GtkFileChooser
855 * @action: the action that the file selector is performing
857 * Sets the type of operation that the chooser is performing; the
858 * user interface is adapted to suit the selected action. For example,
859 * an option to create a new folder might be shown if the action is
860 * %GTK_FILE_CHOOSER_ACTION_SAVE but not if the action is
861 * %GTK_FILE_CHOOSER_ACTION_OPEN.
866 gtk_file_chooser_set_action (GtkFileChooser *chooser,
867 GtkFileChooserAction action)
869 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
871 g_object_set (chooser, "action", action, NULL);
875 * gtk_file_chooser_get_action:
876 * @chooser: a #GtkFileChooser
878 * Gets the type of operation that the file chooser is performing; see
879 * gtk_file_chooser_set_action().
881 * Return value: the action that the file selector is performing
886 gtk_file_chooser_get_action (GtkFileChooser *chooser)
888 GtkFileChooserAction action;
890 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
892 g_object_get (chooser, "action", &action, NULL);
898 * gtk_file_chooser_set_local_only:
899 * @chooser: a #GtkFileChooser
900 * @local_only: %TRUE if only local files can be selected
902 * Sets whether only local files can be selected in the
903 * file selector. If @local_only is %TRUE (the default),
904 * then the selected file are files are guaranteed to be
905 * accessible through the operating systems native file
906 * file system and therefore the application only
907 * needs to worry about the filename functions in
908 * #GtkFileChooser, like gtk_file_chooser_get_filename(),
909 * rather than the URI functions like
910 * gtk_file_chooser_get_uri(),
915 gtk_file_chooser_set_local_only (GtkFileChooser *chooser,
918 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
920 g_object_set (chooser, "local-only", local_only, NULL);
924 * gtk_file_chooser_get_local_only:
925 * @chooser: a #GtkFileChooser
927 * Gets whether only local files can be selected in the
928 * file selector. See gtk_file_chooser_set_local_only()
930 * Return value: %TRUE if only local files can be selected.
935 gtk_file_chooser_get_local_only (GtkFileChooser *chooser)
939 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
941 g_object_get (chooser, "local-only", &local_only, NULL);
947 * gtk_file_chooser_set_select_multiple:
948 * @chooser: a #GtkFileChooser
949 * @select_multiple: %TRUE if multiple files can be selected.
951 * Sets whether multiple files can be selected in the file selector. This is
952 * only relevant if the action is set to be %GTK_FILE_CHOOSER_ACTION_OPEN or
953 * %GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER.
958 gtk_file_chooser_set_select_multiple (GtkFileChooser *chooser,
959 gboolean select_multiple)
961 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
963 g_object_set (chooser, "select-multiple", select_multiple, NULL);
967 * gtk_file_chooser_get_select_multiple:
968 * @chooser: a #GtkFileChooser
970 * Gets whether multiple files can be selected in the file
971 * selector. See gtk_file_chooser_set_select_multiple().
973 * Return value: %TRUE if multiple files can be selected.
978 gtk_file_chooser_get_select_multiple (GtkFileChooser *chooser)
980 gboolean select_multiple;
982 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
984 g_object_get (chooser, "select-multiple", &select_multiple, NULL);
986 return select_multiple;
990 * gtk_file_chooser_set_create_folders:
991 * @chooser: a #GtkFileChooser
992 * @create_folders: %TRUE if the New Folder button should be displayed
994 * Sets whether file choser will offer to create new folders.
995 * This is only relevant if the action is not set to be
996 * %GTK_FILE_CHOOSER_ACTION_OPEN.
1001 gtk_file_chooser_set_create_folders (GtkFileChooser *chooser,
1002 gboolean create_folders)
1004 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1006 g_object_set (chooser, "create-folders", create_folders, NULL);
1010 * gtk_file_chooser_get_create_folders:
1011 * @chooser: a #GtkFileChooser
1013 * Gets whether file choser will offer to create new folders.
1014 * See gtk_file_chooser_set_create_folders().
1016 * Return value: %TRUE if the New Folder button should be displayed.
1021 gtk_file_chooser_get_create_folders (GtkFileChooser *chooser)
1023 gboolean create_folders;
1025 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1027 g_object_get (chooser, "create-folders", &create_folders, NULL);
1029 return create_folders;
1033 * gtk_file_chooser_get_filename:
1034 * @chooser: a #GtkFileChooser
1036 * Gets the filename for the currently selected file in
1037 * the file selector. If multiple files are selected,
1038 * one of the filenames will be returned at random.
1040 * If the file chooser is in folder mode, this function returns the selected
1043 * Return value: (type filename): The currently selected filename, or %NULL
1044 * if no file is selected, or the selected file can't
1045 * be represented with a local filename. Free with g_free().
1050 gtk_file_chooser_get_filename (GtkFileChooser *chooser)
1053 gchar *result = NULL;
1055 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1057 file = gtk_file_chooser_get_file (chooser);
1061 result = g_file_get_path (file);
1062 g_object_unref (file);
1069 * gtk_file_chooser_set_filename:
1070 * @chooser: a #GtkFileChooser
1071 * @filename: (type filename): the filename to set as current
1073 * Sets @filename as the current filename for the file chooser, by changing to
1074 * the file's parent folder and actually selecting the file in list; all other
1075 * files will be unselected. If the @chooser is in
1076 * %GTK_FILE_CHOOSER_ACTION_SAVE mode, the file's base name will also appear in
1077 * the dialog's file name entry.
1079 * Note that the file must exist, or nothing will be done except
1080 * for the directory change.
1082 * You should use this function only when implementing a <guimenuitem>File/Save
1083 * As...</guimenuitem> dialog for which you already have a file name to which
1084 * the user may save. For example, when the user opens an existing file and
1085 * then does <guimenuitem>File/Save As...</guimenuitem> on it to save a copy or
1086 * a modified version. If you don't have a file name already — for
1087 * example, if the user just created a new file and is saving it for the first
1088 * time, do not call this function. Instead, use something similar to this:
1090 * if (document_is_new)
1092 * /* the user just created a new document */
1093 * gtk_file_chooser_set_current_name (chooser, "Untitled document");
1097 * /* the user edited an existing document */
1098 * gtk_file_chooser_set_filename (chooser, existing_filename);
1102 * In the first case, the file chooser will present the user with useful suggestions
1103 * as to where to save his new file. In the second case, the file's existing location
1104 * is already known, so the file chooser will use it.
1106 * Return value: Not useful.
1111 gtk_file_chooser_set_filename (GtkFileChooser *chooser,
1112 const gchar *filename)
1114 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1116 gtk_file_chooser_unselect_all (chooser);
1117 return gtk_file_chooser_select_filename (chooser, filename);
1121 * gtk_file_chooser_select_filename:
1122 * @chooser: a #GtkFileChooser
1123 * @filename: (type filename): the filename to select
1125 * Selects a filename. If the file name isn't in the current
1126 * folder of @chooser, then the current folder of @chooser will
1127 * be changed to the folder containing @filename.
1129 * Return value: Not useful.
1131 * See also: gtk_file_chooser_set_filename()
1136 gtk_file_chooser_select_filename (GtkFileChooser *chooser,
1137 const gchar *filename)
1142 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1143 g_return_val_if_fail (filename != NULL, FALSE);
1145 file = g_file_new_for_path (filename);
1146 result = gtk_file_chooser_select_file (chooser, file, NULL);
1147 g_object_unref (file);
1153 * gtk_file_chooser_unselect_filename:
1154 * @chooser: a #GtkFileChooser
1155 * @filename: (type filename): the filename to unselect
1157 * Unselects a currently selected filename. If the filename
1158 * is not in the current directory, does not exist, or
1159 * is otherwise not currently selected, does nothing.
1164 gtk_file_chooser_unselect_filename (GtkFileChooser *chooser,
1165 const char *filename)
1169 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1170 g_return_if_fail (filename != NULL);
1172 file = g_file_new_for_path (filename);
1173 gtk_file_chooser_unselect_file (chooser, file);
1174 g_object_unref (file);
1177 /* Converts a list of GFile* to a list of strings using the specified function */
1179 files_to_strings (GSList *files,
1180 gchar * (*convert_func) (GFile *file))
1186 for (; files; files = files->next)
1192 string = (* convert_func) (file);
1195 strings = g_slist_prepend (strings, string);
1198 return g_slist_reverse (strings);
1202 * gtk_file_chooser_get_filenames:
1203 * @chooser: a #GtkFileChooser
1205 * Lists all the selected files and subfolders in the current folder of
1206 * @chooser. The returned names are full absolute paths. If files in the current
1207 * folder cannot be represented as local filenames they will be ignored. (See
1208 * gtk_file_chooser_get_uris())
1210 * Return value: (element-type filename) (transfer full): a #GSList
1211 * containing the filenames of all selected files and subfolders in
1212 * the current folder. Free the returned list with g_slist_free(),
1213 * and the filenames with g_free().
1218 gtk_file_chooser_get_filenames (GtkFileChooser *chooser)
1220 GSList *files, *result;
1222 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1224 files = gtk_file_chooser_get_files (chooser);
1226 result = files_to_strings (files, g_file_get_path);
1227 g_slist_foreach (files, (GFunc) g_object_unref, NULL);
1228 g_slist_free (files);
1234 * gtk_file_chooser_set_current_folder:
1235 * @chooser: a #GtkFileChooser
1236 * @filename: (type filename): the full path of the new current folder
1238 * Sets the current folder for @chooser from a local filename.
1239 * The user will be shown the full contents of the current folder,
1240 * plus user interface elements for navigating to other folders.
1242 * In general, you should not use this function. See the <link
1243 * linkend="gtkfilechooserdialog-setting-up">section on setting up a file
1244 * chooser dialog</link> for the rationale behind this.
1246 * Return value: Not useful.
1251 gtk_file_chooser_set_current_folder (GtkFileChooser *chooser,
1252 const gchar *filename)
1257 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1258 g_return_val_if_fail (filename != NULL, FALSE);
1260 file = g_file_new_for_path (filename);
1261 result = gtk_file_chooser_set_current_folder_file (chooser, file, NULL);
1262 g_object_unref (file);
1268 * gtk_file_chooser_get_current_folder:
1269 * @chooser: a #GtkFileChooser
1271 * Gets the current folder of @chooser as a local filename.
1272 * See gtk_file_chooser_set_current_folder().
1274 * Note that this is the folder that the file chooser is currently displaying
1275 * (e.g. "/home/username/Documents"), which is <emphasis>not the same</emphasis>
1276 * as the currently-selected folder if the chooser is in
1277 * %GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER mode
1278 * (e.g. "/home/username/Documents/selected-folder/". To get the
1279 * currently-selected folder in that mode, use gtk_file_chooser_get_uri() as the
1280 * usual way to get the selection.
1282 * Return value: (type filename): the full path of the current folder,
1283 * or %NULL if the current path cannot be represented as a local
1284 * filename. Free with g_free(). This function will also return
1285 * %NULL if the file chooser was unable to load the last folder that
1286 * was requested from it; for example, as would be for calling
1287 * gtk_file_chooser_set_current_folder() on a nonexistent folder.
1292 gtk_file_chooser_get_current_folder (GtkFileChooser *chooser)
1297 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1299 file = gtk_file_chooser_get_current_folder_file (chooser);
1303 filename = g_file_get_path (file);
1304 g_object_unref (file);
1310 * gtk_file_chooser_set_current_name:
1311 * @chooser: a #GtkFileChooser
1312 * @name: (type filename): the filename to use, as a UTF-8 string
1314 * Sets the current name in the file selector, as if entered
1315 * by the user. Note that the name passed in here is a UTF-8
1316 * string rather than a filename. This function is meant for
1317 * such uses as a suggested name in a "Save As..." dialog. You can
1318 * pass "Untitled.doc" or a similarly suitable suggestion for the @name.
1320 * If you want to preselect a particular existing file, you should use
1321 * gtk_file_chooser_set_filename() or gtk_file_chooser_set_uri() instead.
1322 * Please see the documentation for those functions for an example of using
1323 * gtk_file_chooser_set_current_name() as well.
1328 gtk_file_chooser_set_current_name (GtkFileChooser *chooser,
1331 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1332 g_return_if_fail (name != NULL);
1334 GTK_FILE_CHOOSER_GET_IFACE (chooser)->set_current_name (chooser, name);
1338 * gtk_file_chooser_get_uri:
1339 * @chooser: a #GtkFileChooser
1341 * Gets the URI for the currently selected file in
1342 * the file selector. If multiple files are selected,
1343 * one of the filenames will be returned at random.
1345 * If the file chooser is in folder mode, this function returns the selected
1348 * Return value: The currently selected URI, or %NULL
1349 * if no file is selected. Free with g_free()
1354 gtk_file_chooser_get_uri (GtkFileChooser *chooser)
1357 gchar *result = NULL;
1359 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1361 file = gtk_file_chooser_get_file (chooser);
1364 result = g_file_get_uri (file);
1365 g_object_unref (file);
1372 * gtk_file_chooser_set_uri:
1373 * @chooser: a #GtkFileChooser
1374 * @uri: the URI to set as current
1376 * Sets the file referred to by @uri as the current file for the file chooser,
1377 * by changing to the URI's parent folder and actually selecting the URI in the
1378 * list. If the @chooser is %GTK_FILE_CHOOSER_ACTION_SAVE mode, the URI's base
1379 * name will also appear in the dialog's file name entry.
1381 * Note that the URI must exist, or nothing will be done except for the
1384 * You should use this function only when implementing a <guimenuitem>File/Save
1385 * As...</guimenuitem> dialog for which you already have a file name to which
1386 * the user may save. For example, whenthe user opens an existing file and then
1387 * does <guimenuitem>File/Save As...</guimenuitem> on it to save a copy or a
1388 * modified version. If you don't have a file name already — for example,
1389 * if the user just created a new file and is saving it for the first time, do
1390 * not call this function. Instead, use something similar to this:
1392 * if (document_is_new)
1394 * /* the user just created a new document */
1395 * gtk_file_chooser_set_current_name (chooser, "Untitled document");
1399 * /* the user edited an existing document */
1400 * gtk_file_chooser_set_uri (chooser, existing_uri);
1405 * In the first case, the file chooser will present the user with useful suggestions
1406 * as to where to save his new file. In the second case, the file's existing location
1407 * is already known, so the file chooser will use it.
1409 * Return value: Not useful.
1414 gtk_file_chooser_set_uri (GtkFileChooser *chooser,
1417 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1419 gtk_file_chooser_unselect_all (chooser);
1420 return gtk_file_chooser_select_uri (chooser, uri);
1424 * gtk_file_chooser_select_uri:
1425 * @chooser: a #GtkFileChooser
1426 * @uri: the URI to select
1428 * Selects the file to by @uri. If the URI doesn't refer to a
1429 * file in the current folder of @chooser, then the current folder of
1430 * @chooser will be changed to the folder containing @filename.
1432 * Return value: Not useful.
1437 gtk_file_chooser_select_uri (GtkFileChooser *chooser,
1443 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1444 g_return_val_if_fail (uri != NULL, FALSE);
1446 file = g_file_new_for_uri (uri);
1447 result = gtk_file_chooser_select_file (chooser, file, NULL);
1448 g_object_unref (file);
1454 * gtk_file_chooser_unselect_uri:
1455 * @chooser: a #GtkFileChooser
1456 * @uri: the URI to unselect
1458 * Unselects the file referred to by @uri. If the file
1459 * is not in the current directory, does not exist, or
1460 * is otherwise not currently selected, does nothing.
1465 gtk_file_chooser_unselect_uri (GtkFileChooser *chooser,
1470 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1471 g_return_if_fail (uri != NULL);
1473 file = g_file_new_for_uri (uri);
1474 gtk_file_chooser_unselect_file (chooser, file);
1475 g_object_unref (file);
1479 * gtk_file_chooser_select_all:
1480 * @chooser: a #GtkFileChooser
1482 * Selects all the files in the current folder of a file chooser.
1487 gtk_file_chooser_select_all (GtkFileChooser *chooser)
1489 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1491 GTK_FILE_CHOOSER_GET_IFACE (chooser)->select_all (chooser);
1495 * gtk_file_chooser_unselect_all:
1496 * @chooser: a #GtkFileChooser
1498 * Unselects all the files in the current folder of a file chooser.
1503 gtk_file_chooser_unselect_all (GtkFileChooser *chooser)
1506 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1508 GTK_FILE_CHOOSER_GET_IFACE (chooser)->unselect_all (chooser);
1512 * gtk_file_chooser_get_uris:
1513 * @chooser: a #GtkFileChooser
1515 * Lists all the selected files and subfolders in the current folder of
1516 * @chooser. The returned names are full absolute URIs.
1518 * Return value: (element-type utf8) (transfer full): a #GSList containing the URIs of all selected
1519 * files and subfolders in the current folder. Free the returned list
1520 * with g_slist_free(), and the filenames with g_free().
1525 gtk_file_chooser_get_uris (GtkFileChooser *chooser)
1527 GSList *files, *result;
1529 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1531 files = gtk_file_chooser_get_files (chooser);
1533 result = files_to_strings (files, g_file_get_uri);
1534 g_slist_foreach (files, (GFunc) g_object_unref, NULL);
1535 g_slist_free (files);
1541 * gtk_file_chooser_set_current_folder_uri:
1542 * @chooser: a #GtkFileChooser
1543 * @uri: the URI for the new current folder
1545 * Sets the current folder for @chooser from an URI.
1546 * The user will be shown the full contents of the current folder,
1547 * plus user interface elements for navigating to other folders.
1549 * In general, you should not use this function. See the <link
1550 * linkend="gtkfilechooserdialog-setting-up">section on setting up a file
1551 * chooser dialog</link> for the rationale behind this.
1553 * Return value: %TRUE if the folder could be changed successfully, %FALSE
1559 gtk_file_chooser_set_current_folder_uri (GtkFileChooser *chooser,
1565 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1566 g_return_val_if_fail (uri != NULL, FALSE);
1568 file = g_file_new_for_uri (uri);
1569 result = gtk_file_chooser_set_current_folder_file (chooser, file, NULL);
1570 g_object_unref (file);
1576 * gtk_file_chooser_get_current_folder_uri:
1577 * @chooser: a #GtkFileChooser
1579 * Gets the current folder of @chooser as an URI.
1580 * See gtk_file_chooser_set_current_folder_uri().
1582 * Note that this is the folder that the file chooser is currently displaying
1583 * (e.g. "file:///home/username/Documents"), which is <emphasis>not the same</emphasis>
1584 * as the currently-selected folder if the chooser is in
1585 * %GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER mode
1586 * (e.g. "file:///home/username/Documents/selected-folder/". To get the
1587 * currently-selected folder in that mode, use gtk_file_chooser_get_uri() as the
1588 * usual way to get the selection.
1590 * Return value: the URI for the current folder. Free with g_free(). This
1591 * function will also return %NULL if the file chooser was unable to load the
1592 * last folder that was requested from it; for example, as would be for calling
1593 * gtk_file_chooser_set_current_folder_uri() on a nonexistent folder.
1598 gtk_file_chooser_get_current_folder_uri (GtkFileChooser *chooser)
1603 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1605 file = gtk_file_chooser_get_current_folder_file (chooser);
1609 uri = g_file_get_uri (file);
1610 g_object_unref (file);
1616 * gtk_file_chooser_set_current_folder_file:
1617 * @chooser: a #GtkFileChooser
1618 * @file: the #GFile for the new folder
1619 * @error: (allow-none): location to store error, or %NULL.
1621 * Sets the current folder for @chooser from a #GFile.
1622 * Internal function, see gtk_file_chooser_set_current_folder_uri().
1624 * Return value: %TRUE if the folder could be changed successfully, %FALSE
1630 gtk_file_chooser_set_current_folder_file (GtkFileChooser *chooser,
1634 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1635 g_return_val_if_fail (G_IS_FILE (file), FALSE);
1636 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
1638 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->set_current_folder (chooser, file, error);
1642 * gtk_file_chooser_get_current_folder_file:
1643 * @chooser: a #GtkFileChooser
1645 * Gets the current folder of @chooser as #GFile.
1646 * See gtk_file_chooser_get_current_folder_uri().
1648 * Return value: (transfer full): the #GFile for the current folder.
1653 gtk_file_chooser_get_current_folder_file (GtkFileChooser *chooser)
1655 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1657 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_current_folder (chooser);
1661 * gtk_file_chooser_select_file:
1662 * @chooser: a #GtkFileChooser
1663 * @file: the file to select
1664 * @error: (allow-none): location to store error, or %NULL
1666 * Selects the file referred to by @file. An internal function. See
1667 * _gtk_file_chooser_select_uri().
1669 * Return value: Not useful.
1674 gtk_file_chooser_select_file (GtkFileChooser *chooser,
1678 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1679 g_return_val_if_fail (G_IS_FILE (file), FALSE);
1680 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
1682 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->select_file (chooser, file, error);
1686 * gtk_file_chooser_unselect_file:
1687 * @chooser: a #GtkFileChooser
1690 * Unselects the file referred to by @file. If the file is not in the current
1691 * directory, does not exist, or is otherwise not currently selected, does nothing.
1696 gtk_file_chooser_unselect_file (GtkFileChooser *chooser,
1699 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1700 g_return_if_fail (G_IS_FILE (file));
1702 GTK_FILE_CHOOSER_GET_IFACE (chooser)->unselect_file (chooser, file);
1706 * gtk_file_chooser_get_files:
1707 * @chooser: a #GtkFileChooser
1709 * Lists all the selected files and subfolders in the current folder of @chooser
1710 * as #GFile. An internal function, see gtk_file_chooser_get_uris().
1712 * Return value: (element-type GFile) (transfer full): a #GSList
1713 * containing a #GFile for each selected file and subfolder in the
1714 * current folder. Free the returned list with g_slist_free(), and
1715 * the files with g_object_unref().
1720 gtk_file_chooser_get_files (GtkFileChooser *chooser)
1722 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1724 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_files (chooser);
1728 * gtk_file_chooser_set_file:
1729 * @chooser: a #GtkFileChooser
1730 * @file: the #GFile to set as current
1731 * @error: (allow-none): location to store the error, or %NULL to ignore errors.
1733 * Sets @file as the current filename for the file chooser, by changing
1734 * to the file's parent folder and actually selecting the file in list. If
1735 * the @chooser is in %GTK_FILE_CHOOSER_ACTION_SAVE mode, the file's base name
1736 * will also appear in the dialog's file name entry.
1738 * If the file name isn't in the current folder of @chooser, then the current
1739 * folder of @chooser will be changed to the folder containing @filename. This
1740 * is equivalent to a sequence of gtk_file_chooser_unselect_all() followed by
1741 * gtk_file_chooser_select_filename().
1743 * Note that the file must exist, or nothing will be done except
1744 * for the directory change.
1746 * If you are implementing a <guimenuitem>File/Save As...</guimenuitem> dialog,
1747 * you should use this function if you already have a file name to which the
1748 * user may save; for example, when the user opens an existing file and then
1749 * does <guimenuitem>File/Save As...</guimenuitem> on it. If you don't have
1750 * a file name already — for example, if the user just created a new
1751 * file and is saving it for the first time, do not call this function.
1752 * Instead, use something similar to this:
1754 * if (document_is_new)
1756 * /* the user just created a new document */
1757 * gtk_file_chooser_set_current_folder_file (chooser, default_file_for_saving);
1758 * gtk_file_chooser_set_current_name (chooser, "Untitled document");
1762 * /* the user edited an existing document */
1763 * gtk_file_chooser_set_file (chooser, existing_file);
1767 * Return value: Not useful.
1772 gtk_file_chooser_set_file (GtkFileChooser *chooser,
1776 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1777 g_return_val_if_fail (G_IS_FILE (file), FALSE);
1778 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
1780 gtk_file_chooser_unselect_all (chooser);
1781 return gtk_file_chooser_select_file (chooser, file, error);
1785 * gtk_file_chooser_get_file:
1786 * @chooser: a #GtkFileChooser
1788 * Gets the #GFile for the currently selected file in
1789 * the file selector. If multiple files are selected,
1790 * one of the files will be returned at random.
1792 * If the file chooser is in folder mode, this function returns the selected
1795 * Returns: (transfer full): a selected #GFile. You own the returned file;
1796 * use g_object_unref() to release it.
1801 gtk_file_chooser_get_file (GtkFileChooser *chooser)
1804 GFile *result = NULL;
1806 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1808 list = gtk_file_chooser_get_files (chooser);
1811 result = list->data;
1812 list = g_slist_delete_link (list, list);
1814 g_slist_foreach (list, (GFunc) g_object_unref, NULL);
1815 g_slist_free (list);
1822 * _gtk_file_chooser_get_file_system:
1823 * @chooser: a #GtkFileChooser
1825 * Gets the #GtkFileSystem of @chooser; this is an internal
1826 * implementation detail, used for conversion between paths
1827 * and filenames and URIs.
1829 * Return value: the file system for @chooser.
1834 _gtk_file_chooser_get_file_system (GtkFileChooser *chooser)
1836 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1838 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_file_system (chooser);
1844 * gtk_file_chooser_set_preview_widget:
1845 * @chooser: a #GtkFileChooser
1846 * @preview_widget: widget for displaying preview.
1848 * Sets an application-supplied widget to use to display a custom preview
1849 * of the currently selected file. To implement a preview, after setting the
1850 * preview widget, you connect to the #GtkFileChooser::update-preview
1851 * signal, and call gtk_file_chooser_get_preview_filename() or
1852 * gtk_file_chooser_get_preview_uri() on each change. If you can
1853 * display a preview of the new file, update your widget and
1854 * set the preview active using gtk_file_chooser_set_preview_widget_active().
1855 * Otherwise, set the preview inactive.
1857 * When there is no application-supplied preview widget, or the
1858 * application-supplied preview widget is not active, the file chooser
1859 * may display an internally generated preview of the current file or
1860 * it may display no preview at all.
1865 gtk_file_chooser_set_preview_widget (GtkFileChooser *chooser,
1866 GtkWidget *preview_widget)
1868 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1870 g_object_set (chooser, "preview-widget", preview_widget, NULL);
1874 * gtk_file_chooser_get_preview_widget:
1875 * @chooser: a #GtkFileChooser
1877 * Gets the current preview widget; see
1878 * gtk_file_chooser_set_preview_widget().
1880 * Return value: (transfer none): the current preview widget, or %NULL
1885 gtk_file_chooser_get_preview_widget (GtkFileChooser *chooser)
1887 GtkWidget *preview_widget;
1889 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1891 g_object_get (chooser, "preview-widget", &preview_widget, NULL);
1893 /* Horrid hack; g_object_get() refs returned objects but
1894 * that contradicts the memory management conventions
1898 g_object_unref (preview_widget);
1900 return preview_widget;
1904 * gtk_file_chooser_set_preview_widget_active:
1905 * @chooser: a #GtkFileChooser
1906 * @active: whether to display the user-specified preview widget
1908 * Sets whether the preview widget set by
1909 * gtk_file_chooser_set_preview_widget() should be shown for the
1910 * current filename. When @active is set to false, the file chooser
1911 * may display an internally generated preview of the current file
1912 * or it may display no preview at all. See
1913 * gtk_file_chooser_set_preview_widget() for more details.
1918 gtk_file_chooser_set_preview_widget_active (GtkFileChooser *chooser,
1921 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1923 g_object_set (chooser, "preview-widget-active", active, NULL);
1927 * gtk_file_chooser_get_preview_widget_active:
1928 * @chooser: a #GtkFileChooser
1930 * Gets whether the preview widget set by gtk_file_chooser_set_preview_widget()
1931 * should be shown for the current filename. See
1932 * gtk_file_chooser_set_preview_widget_active().
1934 * Return value: %TRUE if the preview widget is active for the current filename.
1939 gtk_file_chooser_get_preview_widget_active (GtkFileChooser *chooser)
1943 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1945 g_object_get (chooser, "preview-widget-active", &active, NULL);
1951 * gtk_file_chooser_set_use_preview_label:
1952 * @chooser: a #GtkFileChooser
1953 * @use_label: whether to display a stock label with the name of the previewed file
1955 * Sets whether the file chooser should display a stock label with the name of
1956 * the file that is being previewed; the default is %TRUE. Applications that
1957 * want to draw the whole preview area themselves should set this to %FALSE and
1958 * display the name themselves in their preview widget.
1960 * See also: gtk_file_chooser_set_preview_widget()
1965 gtk_file_chooser_set_use_preview_label (GtkFileChooser *chooser,
1968 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1970 g_object_set (chooser, "use-preview-label", use_label, NULL);
1974 * gtk_file_chooser_get_use_preview_label:
1975 * @chooser: a #GtkFileChooser
1977 * Gets whether a stock label should be drawn with the name of the previewed
1978 * file. See gtk_file_chooser_set_use_preview_label().
1980 * Return value: %TRUE if the file chooser is set to display a label with the
1981 * name of the previewed file, %FALSE otherwise.
1984 gtk_file_chooser_get_use_preview_label (GtkFileChooser *chooser)
1988 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1990 g_object_get (chooser, "use-preview-label", &use_label, NULL);
1996 * gtk_file_chooser_get_preview_file:
1997 * @chooser: a #GtkFileChooser
1999 * Gets the #GFile that should be previewed in a custom preview
2000 * Internal function, see gtk_file_chooser_get_preview_uri().
2002 * Return value: (transfer full): the #GFile for the file to preview,
2003 * or %NULL if no file is selected. Free with g_object_unref().
2008 gtk_file_chooser_get_preview_file (GtkFileChooser *chooser)
2010 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2012 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_preview_file (chooser);
2016 * _gtk_file_chooser_add_shortcut_folder:
2017 * @chooser: a #GtkFileChooser
2018 * @file: file for the folder to add
2019 * @error: (allow-none): location to store error, or %NULL
2021 * Adds a folder to be displayed with the shortcut folders in a file chooser.
2022 * Internal function, see gtk_file_chooser_add_shortcut_folder().
2024 * Return value: %TRUE if the folder could be added successfully, %FALSE
2030 _gtk_file_chooser_add_shortcut_folder (GtkFileChooser *chooser,
2034 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2035 g_return_val_if_fail (G_IS_FILE (file), FALSE);
2037 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_shortcut_folder (chooser, file, error);
2041 * _gtk_file_chooser_remove_shortcut_folder:
2042 * @chooser: a #GtkFileChooser
2043 * @file: file for the folder to remove
2044 * @error: (allow-none): location to store error, or %NULL
2046 * Removes a folder from the shortcut folders in a file chooser. Internal
2047 * function, see gtk_file_chooser_remove_shortcut_folder().
2049 * Return value: %TRUE if the folder could be removed successfully, %FALSE
2055 _gtk_file_chooser_remove_shortcut_folder (GtkFileChooser *chooser,
2059 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2060 g_return_val_if_fail (G_IS_FILE (file), FALSE);
2062 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_shortcut_folder (chooser, file, error);
2066 * gtk_file_chooser_get_preview_filename:
2067 * @chooser: a #GtkFileChooser
2069 * Gets the filename that should be previewed in a custom preview
2070 * widget. See gtk_file_chooser_set_preview_widget().
2072 * Return value: (type filename): the filename to preview, or %NULL if
2073 * no file is selected, or if the selected file cannot be represented
2074 * as a local filename. Free with g_free()
2079 gtk_file_chooser_get_preview_filename (GtkFileChooser *chooser)
2082 gchar *result = NULL;
2084 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2086 file = gtk_file_chooser_get_preview_file (chooser);
2089 result = g_file_get_path (file);
2090 g_object_unref (file);
2097 * gtk_file_chooser_get_preview_uri:
2098 * @chooser: a #GtkFileChooser
2100 * Gets the URI that should be previewed in a custom preview
2101 * widget. See gtk_file_chooser_set_preview_widget().
2103 * Return value: the URI for the file to preview, or %NULL if no file is
2104 * selected. Free with g_free().
2109 gtk_file_chooser_get_preview_uri (GtkFileChooser *chooser)
2112 gchar *result = NULL;
2114 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2116 file = gtk_file_chooser_get_preview_file (chooser);
2119 result = g_file_get_uri (file);
2120 g_object_unref (file);
2127 * gtk_file_chooser_set_extra_widget:
2128 * @chooser: a #GtkFileChooser
2129 * @extra_widget: widget for extra options
2131 * Sets an application-supplied widget to provide extra options to the user.
2136 gtk_file_chooser_set_extra_widget (GtkFileChooser *chooser,
2137 GtkWidget *extra_widget)
2139 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
2141 g_object_set (chooser, "extra-widget", extra_widget, NULL);
2145 * gtk_file_chooser_get_extra_widget:
2146 * @chooser: a #GtkFileChooser
2148 * Gets the current preview widget; see
2149 * gtk_file_chooser_set_extra_widget().
2151 * Return value: (transfer none): the current extra widget, or %NULL
2156 gtk_file_chooser_get_extra_widget (GtkFileChooser *chooser)
2158 GtkWidget *extra_widget;
2160 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2162 g_object_get (chooser, "extra-widget", &extra_widget, NULL);
2164 /* Horrid hack; g_object_get() refs returned objects but
2165 * that contradicts the memory management conventions
2169 g_object_unref (extra_widget);
2171 return extra_widget;
2175 * gtk_file_chooser_add_filter:
2176 * @chooser: a #GtkFileChooser
2177 * @filter: a #GtkFileFilter
2179 * Adds @filter to the list of filters that the user can select between.
2180 * When a filter is selected, only files that are passed by that
2181 * filter are displayed.
2183 * Note that the @chooser takes ownership of the filter, so you have to
2184 * ref and sink it if you want to keep a reference.
2189 gtk_file_chooser_add_filter (GtkFileChooser *chooser,
2190 GtkFileFilter *filter)
2192 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
2194 GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_filter (chooser, filter);
2198 * gtk_file_chooser_remove_filter:
2199 * @chooser: a #GtkFileChooser
2200 * @filter: a #GtkFileFilter
2202 * Removes @filter from the list of filters that the user can select between.
2207 gtk_file_chooser_remove_filter (GtkFileChooser *chooser,
2208 GtkFileFilter *filter)
2210 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
2212 GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_filter (chooser, filter);
2216 * gtk_file_chooser_list_filters:
2217 * @chooser: a #GtkFileChooser
2219 * Lists the current set of user-selectable filters; see
2220 * gtk_file_chooser_add_filter(), gtk_file_chooser_remove_filter().
2222 * Return value: (element-type GtkFileFilter) (transfer container): a
2223 * #GSList containing the current set of user selectable filters. The
2224 * contents of the list are owned by GTK+, but you must free the list
2225 * itself with g_slist_free() when you are done with it.
2230 gtk_file_chooser_list_filters (GtkFileChooser *chooser)
2232 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2234 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->list_filters (chooser);
2238 * gtk_file_chooser_set_filter:
2239 * @chooser: a #GtkFileChooser
2240 * @filter: a #GtkFileFilter
2242 * Sets the current filter; only the files that pass the
2243 * filter will be displayed. If the user-selectable list of filters
2244 * is non-empty, then the filter should be one of the filters
2245 * in that list. Setting the current filter when the list of
2246 * filters is empty is useful if you want to restrict the displayed
2247 * set of files without letting the user change it.
2252 gtk_file_chooser_set_filter (GtkFileChooser *chooser,
2253 GtkFileFilter *filter)
2255 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
2256 g_return_if_fail (GTK_IS_FILE_FILTER (filter));
2258 g_object_set (chooser, "filter", filter, NULL);
2262 * gtk_file_chooser_get_filter:
2263 * @chooser: a #GtkFileChooser
2265 * Gets the current filter; see gtk_file_chooser_set_filter().
2267 * Return value: (transfer none): the current filter, or %NULL
2272 gtk_file_chooser_get_filter (GtkFileChooser *chooser)
2274 GtkFileFilter *filter;
2276 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2278 g_object_get (chooser, "filter", &filter, NULL);
2279 /* Horrid hack; g_object_get() refs returned objects but
2280 * that contradicts the memory management conventions
2284 g_object_unref (filter);
2290 * gtk_file_chooser_add_shortcut_folder:
2291 * @chooser: a #GtkFileChooser
2292 * @folder: (type filename): filename of the folder to add
2293 * @error: (allow-none): location to store error, or %NULL
2295 * Adds a folder to be displayed with the shortcut folders in a file chooser.
2296 * Note that shortcut folders do not get saved, as they are provided by the
2297 * application. For example, you can use this to add a
2298 * "/usr/share/mydrawprogram/Clipart" folder to the volume list.
2300 * Return value: %TRUE if the folder could be added successfully, %FALSE
2301 * otherwise. In the latter case, the @error will be set as appropriate.
2306 gtk_file_chooser_add_shortcut_folder (GtkFileChooser *chooser,
2313 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2314 g_return_val_if_fail (folder != NULL, FALSE);
2316 file = g_file_new_for_path (folder);
2317 result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_shortcut_folder (chooser, file, error);
2318 g_object_unref (file);
2324 * gtk_file_chooser_remove_shortcut_folder:
2325 * @chooser: a #GtkFileChooser
2326 * @folder: (type filename): filename of the folder to remove
2327 * @error: (allow-none): location to store error, or %NULL
2329 * Removes a folder from a file chooser's list of shortcut folders.
2331 * Return value: %TRUE if the operation succeeds, %FALSE otherwise.
2332 * In the latter case, the @error will be set as appropriate.
2334 * See also: gtk_file_chooser_add_shortcut_folder()
2339 gtk_file_chooser_remove_shortcut_folder (GtkFileChooser *chooser,
2346 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2347 g_return_val_if_fail (folder != NULL, FALSE);
2349 file = g_file_new_for_path (folder);
2350 result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_shortcut_folder (chooser, file, error);
2351 g_object_unref (file);
2357 * gtk_file_chooser_list_shortcut_folders:
2358 * @chooser: a #GtkFileChooser
2360 * Queries the list of shortcut folders in the file chooser, as set by
2361 * gtk_file_chooser_add_shortcut_folder().
2363 * Return value: (element-type filename) (transfer full): A list of
2364 * folder filenames, or %NULL if there are no shortcut folders. Free
2365 * the returned list with g_slist_free(), and the filenames with
2371 gtk_file_chooser_list_shortcut_folders (GtkFileChooser *chooser)
2376 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2378 folders = _gtk_file_chooser_list_shortcut_folder_files (chooser);
2380 result = files_to_strings (folders, g_file_get_path);
2381 g_slist_foreach (folders, (GFunc) g_object_unref, NULL);
2382 g_slist_free (folders);
2388 * gtk_file_chooser_add_shortcut_folder_uri:
2389 * @chooser: a #GtkFileChooser
2390 * @uri: URI of the folder to add
2391 * @error: (allow-none): location to store error, or %NULL
2393 * Adds a folder URI to be displayed with the shortcut folders in a file
2394 * chooser. Note that shortcut folders do not get saved, as they are provided
2395 * by the application. For example, you can use this to add a
2396 * "file:///usr/share/mydrawprogram/Clipart" folder to the volume list.
2398 * Return value: %TRUE if the folder could be added successfully, %FALSE
2399 * otherwise. In the latter case, the @error will be set as appropriate.
2404 gtk_file_chooser_add_shortcut_folder_uri (GtkFileChooser *chooser,
2411 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2412 g_return_val_if_fail (uri != NULL, FALSE);
2414 file = g_file_new_for_uri (uri);
2415 result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_shortcut_folder (chooser, file, error);
2416 g_object_unref (file);
2422 * gtk_file_chooser_remove_shortcut_folder_uri:
2423 * @chooser: a #GtkFileChooser
2424 * @uri: URI of the folder to remove
2425 * @error: (allow-none): location to store error, or %NULL
2427 * Removes a folder URI from a file chooser's list of shortcut folders.
2429 * Return value: %TRUE if the operation succeeds, %FALSE otherwise.
2430 * In the latter case, the @error will be set as appropriate.
2432 * See also: gtk_file_chooser_add_shortcut_folder_uri()
2437 gtk_file_chooser_remove_shortcut_folder_uri (GtkFileChooser *chooser,
2444 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2445 g_return_val_if_fail (uri != NULL, FALSE);
2447 file = g_file_new_for_uri (uri);
2448 result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_shortcut_folder (chooser, file, error);
2449 g_object_unref (file);
2455 * gtk_file_chooser_list_shortcut_folder_uris:
2456 * @chooser: a #GtkFileChooser
2458 * Queries the list of shortcut folders in the file chooser, as set by
2459 * gtk_file_chooser_add_shortcut_folder_uri().
2461 * Return value: (element-type utf8) (transfer full): A list of folder
2462 * URIs, or %NULL if there are no shortcut folders. Free the returned
2463 * list with g_slist_free(), and the URIs with g_free().
2468 gtk_file_chooser_list_shortcut_folder_uris (GtkFileChooser *chooser)
2473 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2475 folders = _gtk_file_chooser_list_shortcut_folder_files (chooser);
2477 result = files_to_strings (folders, g_file_get_uri);
2478 g_slist_foreach (folders, (GFunc) g_object_unref, NULL);
2479 g_slist_free (folders);
2485 _gtk_file_chooser_list_shortcut_folder_files (GtkFileChooser *chooser)
2487 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2489 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->list_shortcut_folders (chooser);
2493 * gtk_file_chooser_set_show_hidden:
2494 * @chooser: a #GtkFileChooser
2495 * @show_hidden: %TRUE if hidden files and folders should be displayed.
2497 * Sets whether hidden files and folders are displayed in the file selector.
2502 gtk_file_chooser_set_show_hidden (GtkFileChooser *chooser,
2503 gboolean show_hidden)
2505 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
2507 g_object_set (chooser, "show-hidden", show_hidden, NULL);
2511 * gtk_file_chooser_get_show_hidden:
2512 * @chooser: a #GtkFileChooser
2514 * Gets whether hidden files and folders are displayed in the file selector.
2515 * See gtk_file_chooser_set_show_hidden().
2517 * Return value: %TRUE if hidden files and folders are displayed.
2522 gtk_file_chooser_get_show_hidden (GtkFileChooser *chooser)
2524 gboolean show_hidden;
2526 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2528 g_object_get (chooser, "show-hidden", &show_hidden, NULL);
2534 * gtk_file_chooser_set_do_overwrite_confirmation:
2535 * @chooser: a #GtkFileChooser
2536 * @do_overwrite_confirmation: whether to confirm overwriting in save mode
2538 * Sets whether a file chooser in %GTK_FILE_CHOOSER_ACTION_SAVE mode will present
2539 * a confirmation dialog if the user types a file name that already exists. This
2540 * is %FALSE by default.
2542 * Regardless of this setting, the @chooser will emit the
2543 * #GtkFileChooser::confirm-overwrite signal when appropriate.
2545 * If all you need is the stock confirmation dialog, set this property to %TRUE.
2546 * You can override the way confirmation is done by actually handling the
2547 * #GtkFileChooser::confirm-overwrite signal; please refer to its documentation
2553 gtk_file_chooser_set_do_overwrite_confirmation (GtkFileChooser *chooser,
2554 gboolean do_overwrite_confirmation)
2556 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
2558 g_object_set (chooser, "do-overwrite-confirmation", do_overwrite_confirmation, NULL);
2562 * gtk_file_chooser_get_do_overwrite_confirmation:
2563 * @chooser: a #GtkFileChooser
2565 * Queries whether a file chooser is set to confirm for overwriting when the user
2566 * types a file name that already exists.
2568 * Return value: %TRUE if the file chooser will present a confirmation dialog;
2574 gtk_file_chooser_get_do_overwrite_confirmation (GtkFileChooser *chooser)
2576 gboolean do_overwrite_confirmation;
2578 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2580 g_object_get (chooser, "do-overwrite-confirmation", &do_overwrite_confirmation, NULL);
2582 return do_overwrite_confirmation;