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(),
913 gtk_file_chooser_set_local_only (GtkFileChooser *chooser,
916 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
918 g_object_set (chooser, "local-only", local_only, NULL);
922 * gtk_file_chooser_get_local_only:
923 * @chooser: a #GtkFileChooser
925 * Gets whether only local files can be selected in the
926 * file selector. See gtk_file_chooser_set_local_only()
928 * Return value: %TRUE if only local files can be selected.
933 gtk_file_chooser_get_local_only (GtkFileChooser *chooser)
937 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
939 g_object_get (chooser, "local-only", &local_only, NULL);
945 * gtk_file_chooser_set_select_multiple:
946 * @chooser: a #GtkFileChooser
947 * @select_multiple: %TRUE if multiple files can be selected.
949 * Sets whether multiple files can be selected in the file selector. This is
950 * only relevant if the action is set to be %GTK_FILE_CHOOSER_ACTION_OPEN or
951 * %GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER.
956 gtk_file_chooser_set_select_multiple (GtkFileChooser *chooser,
957 gboolean select_multiple)
959 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
961 g_object_set (chooser, "select-multiple", select_multiple, NULL);
965 * gtk_file_chooser_get_select_multiple:
966 * @chooser: a #GtkFileChooser
968 * Gets whether multiple files can be selected in the file
969 * selector. See gtk_file_chooser_set_select_multiple().
971 * Return value: %TRUE if multiple files can be selected.
976 gtk_file_chooser_get_select_multiple (GtkFileChooser *chooser)
978 gboolean select_multiple;
980 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
982 g_object_get (chooser, "select-multiple", &select_multiple, NULL);
984 return select_multiple;
988 * gtk_file_chooser_set_create_folders:
989 * @chooser: a #GtkFileChooser
990 * @create_folders: %TRUE if the New Folder button should be displayed
992 * Sets whether file choser will offer to create new folders.
993 * This is only relevant if the action is not set to be
994 * %GTK_FILE_CHOOSER_ACTION_OPEN.
999 gtk_file_chooser_set_create_folders (GtkFileChooser *chooser,
1000 gboolean create_folders)
1002 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1004 g_object_set (chooser, "create-folders", create_folders, NULL);
1008 * gtk_file_chooser_get_create_folders:
1009 * @chooser: a #GtkFileChooser
1011 * Gets whether file choser will offer to create new folders.
1012 * See gtk_file_chooser_set_create_folders().
1014 * Return value: %TRUE if the New Folder button should be displayed.
1019 gtk_file_chooser_get_create_folders (GtkFileChooser *chooser)
1021 gboolean create_folders;
1023 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1025 g_object_get (chooser, "create-folders", &create_folders, NULL);
1027 return create_folders;
1031 * gtk_file_chooser_get_filename:
1032 * @chooser: a #GtkFileChooser
1034 * Gets the filename for the currently selected file in
1035 * the file selector. The filename is returned as an absolute path. If
1036 * multiple files are selected, one of the filenames will be returned at
1039 * If the file chooser is in folder mode, this function returns the selected
1042 * Return value: (type filename): The currently selected filename, or %NULL
1043 * if no file is selected, or the selected file can't
1044 * be represented with a local filename. Free with g_free().
1049 gtk_file_chooser_get_filename (GtkFileChooser *chooser)
1052 gchar *result = NULL;
1054 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1056 file = gtk_file_chooser_get_file (chooser);
1060 result = g_file_get_path (file);
1061 g_object_unref (file);
1068 * gtk_file_chooser_set_filename:
1069 * @chooser: a #GtkFileChooser
1070 * @filename: (type filename): the filename to set as current
1072 * Sets @filename as the current filename for the file chooser, by changing to
1073 * the file's parent folder and actually selecting the file in list; all other
1074 * files will be unselected. If the @chooser is in
1075 * %GTK_FILE_CHOOSER_ACTION_SAVE mode, the file's base name will also appear in
1076 * the dialog's file name entry.
1078 * Note that the file must exist, or nothing will be done except
1079 * for the directory change.
1081 * You should use this function only when implementing a <guimenuitem>File/Save
1082 * As...</guimenuitem> dialog for which you already have a file name to which
1083 * the user may save. For example, when the user opens an existing file and
1084 * then does <guimenuitem>File/Save As...</guimenuitem> on it to save a copy or
1085 * a modified version. If you don't have a file name already — for
1086 * example, if the user just created a new file and is saving it for the first
1087 * time, do not call this function. Instead, use something similar to this:
1089 * if (document_is_new)
1091 * /* the user just created a new document */
1092 * gtk_file_chooser_set_current_name (chooser, "Untitled document");
1096 * /* the user edited an existing document */
1097 * gtk_file_chooser_set_filename (chooser, existing_filename);
1101 * In the first case, the file chooser will present the user with useful suggestions
1102 * as to where to save his new file. In the second case, the file's existing location
1103 * is already known, so the file chooser will use it.
1105 * Return value: Not useful.
1110 gtk_file_chooser_set_filename (GtkFileChooser *chooser,
1111 const gchar *filename)
1113 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1115 gtk_file_chooser_unselect_all (chooser);
1116 return gtk_file_chooser_select_filename (chooser, filename);
1120 * gtk_file_chooser_select_filename:
1121 * @chooser: a #GtkFileChooser
1122 * @filename: (type filename): the filename to select
1124 * Selects a filename. If the file name isn't in the current
1125 * folder of @chooser, then the current folder of @chooser will
1126 * be changed to the folder containing @filename.
1128 * Return value: Not useful.
1130 * See also: gtk_file_chooser_set_filename()
1135 gtk_file_chooser_select_filename (GtkFileChooser *chooser,
1136 const gchar *filename)
1141 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1142 g_return_val_if_fail (filename != NULL, FALSE);
1144 file = g_file_new_for_path (filename);
1145 result = gtk_file_chooser_select_file (chooser, file, NULL);
1146 g_object_unref (file);
1152 * gtk_file_chooser_unselect_filename:
1153 * @chooser: a #GtkFileChooser
1154 * @filename: (type filename): the filename to unselect
1156 * Unselects a currently selected filename. If the filename
1157 * is not in the current directory, does not exist, or
1158 * is otherwise not currently selected, does nothing.
1163 gtk_file_chooser_unselect_filename (GtkFileChooser *chooser,
1164 const char *filename)
1168 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1169 g_return_if_fail (filename != NULL);
1171 file = g_file_new_for_path (filename);
1172 gtk_file_chooser_unselect_file (chooser, file);
1173 g_object_unref (file);
1176 /* Converts a list of GFile* to a list of strings using the specified function */
1178 files_to_strings (GSList *files,
1179 gchar * (*convert_func) (GFile *file))
1185 for (; files; files = files->next)
1191 string = (* convert_func) (file);
1194 strings = g_slist_prepend (strings, string);
1197 return g_slist_reverse (strings);
1201 * gtk_file_chooser_get_filenames:
1202 * @chooser: a #GtkFileChooser
1204 * Lists all the selected files and subfolders in the current folder of
1205 * @chooser. The returned names are full absolute paths. If files in the current
1206 * folder cannot be represented as local filenames they will be ignored. (See
1207 * gtk_file_chooser_get_uris())
1209 * Return value: (element-type filename) (transfer full): a #GSList
1210 * containing the filenames of all selected files and subfolders in
1211 * the current folder. Free the returned list with g_slist_free(),
1212 * and the filenames with g_free().
1217 gtk_file_chooser_get_filenames (GtkFileChooser *chooser)
1219 GSList *files, *result;
1221 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1223 files = gtk_file_chooser_get_files (chooser);
1225 result = files_to_strings (files, g_file_get_path);
1226 g_slist_foreach (files, (GFunc) g_object_unref, NULL);
1227 g_slist_free (files);
1233 * gtk_file_chooser_set_current_folder:
1234 * @chooser: a #GtkFileChooser
1235 * @filename: (type filename): the full path of the new current folder
1237 * Sets the current folder for @chooser from a local filename.
1238 * The user will be shown the full contents of the current folder,
1239 * plus user interface elements for navigating to other folders.
1241 * In general, you should not use this function. See the <link
1242 * linkend="gtkfilechooserdialog-setting-up">section on setting up a file
1243 * chooser dialog</link> for the rationale behind this.
1245 * Return value: Not useful.
1250 gtk_file_chooser_set_current_folder (GtkFileChooser *chooser,
1251 const gchar *filename)
1256 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1257 g_return_val_if_fail (filename != NULL, FALSE);
1259 file = g_file_new_for_path (filename);
1260 result = gtk_file_chooser_set_current_folder_file (chooser, file, NULL);
1261 g_object_unref (file);
1267 * gtk_file_chooser_get_current_folder:
1268 * @chooser: a #GtkFileChooser
1270 * Gets the current folder of @chooser as a local filename.
1271 * See gtk_file_chooser_set_current_folder().
1273 * Note that this is the folder that the file chooser is currently displaying
1274 * (e.g. "/home/username/Documents"), which is <emphasis>not the same</emphasis>
1275 * as the currently-selected folder if the chooser is in
1276 * %GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER mode
1277 * (e.g. "/home/username/Documents/selected-folder/". To get the
1278 * currently-selected folder in that mode, use gtk_file_chooser_get_uri() as the
1279 * usual way to get the selection.
1281 * Return value: (type filename): the full path of the current folder,
1282 * or %NULL if the current path cannot be represented as a local
1283 * filename. Free with g_free(). This function will also return
1284 * %NULL if the file chooser was unable to load the last folder that
1285 * was requested from it; for example, as would be for calling
1286 * gtk_file_chooser_set_current_folder() on a nonexistent folder.
1291 gtk_file_chooser_get_current_folder (GtkFileChooser *chooser)
1296 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1298 file = gtk_file_chooser_get_current_folder_file (chooser);
1302 filename = g_file_get_path (file);
1303 g_object_unref (file);
1309 * gtk_file_chooser_set_current_name:
1310 * @chooser: a #GtkFileChooser
1311 * @name: (type filename): the filename to use, as a UTF-8 string
1313 * Sets the current name in the file selector, as if entered
1314 * by the user. Note that the name passed in here is a UTF-8
1315 * string rather than a filename. This function is meant for
1316 * such uses as a suggested name in a "Save As..." dialog. You can
1317 * pass "Untitled.doc" or a similarly suitable suggestion for the @name.
1319 * If you want to preselect a particular existing file, you should use
1320 * gtk_file_chooser_set_filename() or gtk_file_chooser_set_uri() instead.
1321 * Please see the documentation for those functions for an example of using
1322 * gtk_file_chooser_set_current_name() as well.
1327 gtk_file_chooser_set_current_name (GtkFileChooser *chooser,
1330 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1331 g_return_if_fail (name != NULL);
1333 GTK_FILE_CHOOSER_GET_IFACE (chooser)->set_current_name (chooser, name);
1337 * gtk_file_chooser_get_uri:
1338 * @chooser: a #GtkFileChooser
1340 * Gets the URI for the currently selected file in
1341 * the file selector. If multiple files are selected,
1342 * one of the filenames will be returned at random.
1344 * If the file chooser is in folder mode, this function returns the selected
1347 * Return value: The currently selected URI, or %NULL
1348 * if no file is selected. Free with g_free()
1353 gtk_file_chooser_get_uri (GtkFileChooser *chooser)
1356 gchar *result = NULL;
1358 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1360 file = gtk_file_chooser_get_file (chooser);
1363 result = g_file_get_uri (file);
1364 g_object_unref (file);
1371 * gtk_file_chooser_set_uri:
1372 * @chooser: a #GtkFileChooser
1373 * @uri: the URI to set as current
1375 * Sets the file referred to by @uri as the current file for the file chooser,
1376 * by changing to the URI's parent folder and actually selecting the URI in the
1377 * list. If the @chooser is %GTK_FILE_CHOOSER_ACTION_SAVE mode, the URI's base
1378 * name will also appear in the dialog's file name entry.
1380 * Note that the URI must exist, or nothing will be done except for the
1383 * You should use this function only when implementing a <guimenuitem>File/Save
1384 * As...</guimenuitem> dialog for which you already have a file name to which
1385 * the user may save. For example, whenthe user opens an existing file and then
1386 * does <guimenuitem>File/Save As...</guimenuitem> on it to save a copy or a
1387 * modified version. If you don't have a file name already — for example,
1388 * if the user just created a new file and is saving it for the first time, do
1389 * not call this function. Instead, use something similar to this:
1391 * if (document_is_new)
1393 * /* the user just created a new document */
1394 * gtk_file_chooser_set_current_name (chooser, "Untitled document");
1398 * /* the user edited an existing document */
1399 * gtk_file_chooser_set_uri (chooser, existing_uri);
1404 * In the first case, the file chooser will present the user with useful suggestions
1405 * as to where to save his new file. In the second case, the file's existing location
1406 * is already known, so the file chooser will use it.
1408 * Return value: Not useful.
1413 gtk_file_chooser_set_uri (GtkFileChooser *chooser,
1416 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1418 gtk_file_chooser_unselect_all (chooser);
1419 return gtk_file_chooser_select_uri (chooser, uri);
1423 * gtk_file_chooser_select_uri:
1424 * @chooser: a #GtkFileChooser
1425 * @uri: the URI to select
1427 * Selects the file to by @uri. If the URI doesn't refer to a
1428 * file in the current folder of @chooser, then the current folder of
1429 * @chooser will be changed to the folder containing @filename.
1431 * Return value: Not useful.
1436 gtk_file_chooser_select_uri (GtkFileChooser *chooser,
1442 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1443 g_return_val_if_fail (uri != NULL, FALSE);
1445 file = g_file_new_for_uri (uri);
1446 result = gtk_file_chooser_select_file (chooser, file, NULL);
1447 g_object_unref (file);
1453 * gtk_file_chooser_unselect_uri:
1454 * @chooser: a #GtkFileChooser
1455 * @uri: the URI to unselect
1457 * Unselects the file referred to by @uri. If the file
1458 * is not in the current directory, does not exist, or
1459 * is otherwise not currently selected, does nothing.
1464 gtk_file_chooser_unselect_uri (GtkFileChooser *chooser,
1469 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1470 g_return_if_fail (uri != NULL);
1472 file = g_file_new_for_uri (uri);
1473 gtk_file_chooser_unselect_file (chooser, file);
1474 g_object_unref (file);
1478 * gtk_file_chooser_select_all:
1479 * @chooser: a #GtkFileChooser
1481 * Selects all the files in the current folder of a file chooser.
1486 gtk_file_chooser_select_all (GtkFileChooser *chooser)
1488 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1490 GTK_FILE_CHOOSER_GET_IFACE (chooser)->select_all (chooser);
1494 * gtk_file_chooser_unselect_all:
1495 * @chooser: a #GtkFileChooser
1497 * Unselects all the files in the current folder of a file chooser.
1502 gtk_file_chooser_unselect_all (GtkFileChooser *chooser)
1505 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1507 GTK_FILE_CHOOSER_GET_IFACE (chooser)->unselect_all (chooser);
1511 * gtk_file_chooser_get_uris:
1512 * @chooser: a #GtkFileChooser
1514 * Lists all the selected files and subfolders in the current folder of
1515 * @chooser. The returned names are full absolute URIs.
1517 * Return value: (element-type utf8) (transfer full): a #GSList containing the URIs of all selected
1518 * files and subfolders in the current folder. Free the returned list
1519 * with g_slist_free(), and the filenames with g_free().
1524 gtk_file_chooser_get_uris (GtkFileChooser *chooser)
1526 GSList *files, *result;
1528 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1530 files = gtk_file_chooser_get_files (chooser);
1532 result = files_to_strings (files, g_file_get_uri);
1533 g_slist_foreach (files, (GFunc) g_object_unref, NULL);
1534 g_slist_free (files);
1540 * gtk_file_chooser_set_current_folder_uri:
1541 * @chooser: a #GtkFileChooser
1542 * @uri: the URI for the new current folder
1544 * Sets the current folder for @chooser from an URI.
1545 * The user will be shown the full contents of the current folder,
1546 * plus user interface elements for navigating to other folders.
1548 * In general, you should not use this function. See the <link
1549 * linkend="gtkfilechooserdialog-setting-up">section on setting up a file
1550 * chooser dialog</link> for the rationale behind this.
1552 * Return value: %TRUE if the folder could be changed successfully, %FALSE
1558 gtk_file_chooser_set_current_folder_uri (GtkFileChooser *chooser,
1564 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1565 g_return_val_if_fail (uri != NULL, FALSE);
1567 file = g_file_new_for_uri (uri);
1568 result = gtk_file_chooser_set_current_folder_file (chooser, file, NULL);
1569 g_object_unref (file);
1575 * gtk_file_chooser_get_current_folder_uri:
1576 * @chooser: a #GtkFileChooser
1578 * Gets the current folder of @chooser as an URI.
1579 * See gtk_file_chooser_set_current_folder_uri().
1581 * Note that this is the folder that the file chooser is currently displaying
1582 * (e.g. "file:///home/username/Documents"), which is <emphasis>not the same</emphasis>
1583 * as the currently-selected folder if the chooser is in
1584 * %GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER mode
1585 * (e.g. "file:///home/username/Documents/selected-folder/". To get the
1586 * currently-selected folder in that mode, use gtk_file_chooser_get_uri() as the
1587 * usual way to get the selection.
1589 * Return value: the URI for the current folder. Free with g_free(). This
1590 * function will also return %NULL if the file chooser was unable to load the
1591 * last folder that was requested from it; for example, as would be for calling
1592 * gtk_file_chooser_set_current_folder_uri() on a nonexistent folder.
1597 gtk_file_chooser_get_current_folder_uri (GtkFileChooser *chooser)
1602 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1604 file = gtk_file_chooser_get_current_folder_file (chooser);
1608 uri = g_file_get_uri (file);
1609 g_object_unref (file);
1615 * gtk_file_chooser_set_current_folder_file:
1616 * @chooser: a #GtkFileChooser
1617 * @file: the #GFile for the new folder
1618 * @error: (allow-none): location to store error, or %NULL.
1620 * Sets the current folder for @chooser from a #GFile.
1621 * Internal function, see gtk_file_chooser_set_current_folder_uri().
1623 * Return value: %TRUE if the folder could be changed successfully, %FALSE
1629 gtk_file_chooser_set_current_folder_file (GtkFileChooser *chooser,
1633 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1634 g_return_val_if_fail (G_IS_FILE (file), FALSE);
1635 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
1637 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->set_current_folder (chooser, file, error);
1641 * gtk_file_chooser_get_current_folder_file:
1642 * @chooser: a #GtkFileChooser
1644 * Gets the current folder of @chooser as #GFile.
1645 * See gtk_file_chooser_get_current_folder_uri().
1647 * Return value: (transfer full): the #GFile for the current folder.
1652 gtk_file_chooser_get_current_folder_file (GtkFileChooser *chooser)
1654 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1656 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_current_folder (chooser);
1660 * gtk_file_chooser_select_file:
1661 * @chooser: a #GtkFileChooser
1662 * @file: the file to select
1663 * @error: (allow-none): location to store error, or %NULL
1665 * Selects the file referred to by @file. An internal function. See
1666 * _gtk_file_chooser_select_uri().
1668 * Return value: Not useful.
1673 gtk_file_chooser_select_file (GtkFileChooser *chooser,
1677 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1678 g_return_val_if_fail (G_IS_FILE (file), FALSE);
1679 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
1681 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->select_file (chooser, file, error);
1685 * gtk_file_chooser_unselect_file:
1686 * @chooser: a #GtkFileChooser
1689 * Unselects the file referred to by @file. If the file is not in the current
1690 * directory, does not exist, or is otherwise not currently selected, does nothing.
1695 gtk_file_chooser_unselect_file (GtkFileChooser *chooser,
1698 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1699 g_return_if_fail (G_IS_FILE (file));
1701 GTK_FILE_CHOOSER_GET_IFACE (chooser)->unselect_file (chooser, file);
1705 * gtk_file_chooser_get_files:
1706 * @chooser: a #GtkFileChooser
1708 * Lists all the selected files and subfolders in the current folder of @chooser
1709 * as #GFile. An internal function, see gtk_file_chooser_get_uris().
1711 * Return value: (element-type GFile) (transfer full): a #GSList
1712 * containing a #GFile for each selected file and subfolder in the
1713 * current folder. Free the returned list with g_slist_free(), and
1714 * the files with g_object_unref().
1719 gtk_file_chooser_get_files (GtkFileChooser *chooser)
1721 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1723 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_files (chooser);
1727 * gtk_file_chooser_set_file:
1728 * @chooser: a #GtkFileChooser
1729 * @file: the #GFile to set as current
1730 * @error: (allow-none): location to store the error, or %NULL to ignore errors.
1732 * Sets @file as the current filename for the file chooser, by changing
1733 * to the file's parent folder and actually selecting the file in list. If
1734 * the @chooser is in %GTK_FILE_CHOOSER_ACTION_SAVE mode, the file's base name
1735 * will also appear in the dialog's file name entry.
1737 * If the file name isn't in the current folder of @chooser, then the current
1738 * folder of @chooser will be changed to the folder containing @filename. This
1739 * is equivalent to a sequence of gtk_file_chooser_unselect_all() followed by
1740 * gtk_file_chooser_select_filename().
1742 * Note that the file must exist, or nothing will be done except
1743 * for the directory change.
1745 * If you are implementing a <guimenuitem>File/Save As...</guimenuitem> dialog,
1746 * you should use this function if you already have a file name to which the
1747 * user may save; for example, when the user opens an existing file and then
1748 * does <guimenuitem>File/Save As...</guimenuitem> on it. If you don't have
1749 * a file name already — for example, if the user just created a new
1750 * file and is saving it for the first time, do not call this function.
1751 * Instead, use something similar to this:
1753 * if (document_is_new)
1755 * /* the user just created a new document */
1756 * gtk_file_chooser_set_current_folder_file (chooser, default_file_for_saving);
1757 * gtk_file_chooser_set_current_name (chooser, "Untitled document");
1761 * /* the user edited an existing document */
1762 * gtk_file_chooser_set_file (chooser, existing_file);
1766 * Return value: Not useful.
1771 gtk_file_chooser_set_file (GtkFileChooser *chooser,
1775 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1776 g_return_val_if_fail (G_IS_FILE (file), FALSE);
1777 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
1779 gtk_file_chooser_unselect_all (chooser);
1780 return gtk_file_chooser_select_file (chooser, file, error);
1784 * gtk_file_chooser_get_file:
1785 * @chooser: a #GtkFileChooser
1787 * Gets the #GFile for the currently selected file in
1788 * the file selector. If multiple files are selected,
1789 * one of the files will be returned at random.
1791 * If the file chooser is in folder mode, this function returns the selected
1794 * Returns: (transfer full): a selected #GFile. You own the returned file;
1795 * use g_object_unref() to release it.
1800 gtk_file_chooser_get_file (GtkFileChooser *chooser)
1803 GFile *result = NULL;
1805 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1807 list = gtk_file_chooser_get_files (chooser);
1810 result = list->data;
1811 list = g_slist_delete_link (list, list);
1813 g_slist_foreach (list, (GFunc) g_object_unref, NULL);
1814 g_slist_free (list);
1821 * _gtk_file_chooser_get_file_system:
1822 * @chooser: a #GtkFileChooser
1824 * Gets the #GtkFileSystem of @chooser; this is an internal
1825 * implementation detail, used for conversion between paths
1826 * and filenames and URIs.
1828 * Return value: the file system for @chooser.
1833 _gtk_file_chooser_get_file_system (GtkFileChooser *chooser)
1835 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1837 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_file_system (chooser);
1843 * gtk_file_chooser_set_preview_widget:
1844 * @chooser: a #GtkFileChooser
1845 * @preview_widget: widget for displaying preview.
1847 * Sets an application-supplied widget to use to display a custom preview
1848 * of the currently selected file. To implement a preview, after setting the
1849 * preview widget, you connect to the #GtkFileChooser::update-preview
1850 * signal, and call gtk_file_chooser_get_preview_filename() or
1851 * gtk_file_chooser_get_preview_uri() on each change. If you can
1852 * display a preview of the new file, update your widget and
1853 * set the preview active using gtk_file_chooser_set_preview_widget_active().
1854 * Otherwise, set the preview inactive.
1856 * When there is no application-supplied preview widget, or the
1857 * application-supplied preview widget is not active, the file chooser
1858 * may display an internally generated preview of the current file or
1859 * it may display no preview at all.
1864 gtk_file_chooser_set_preview_widget (GtkFileChooser *chooser,
1865 GtkWidget *preview_widget)
1867 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1869 g_object_set (chooser, "preview-widget", preview_widget, NULL);
1873 * gtk_file_chooser_get_preview_widget:
1874 * @chooser: a #GtkFileChooser
1876 * Gets the current preview widget; see
1877 * gtk_file_chooser_set_preview_widget().
1879 * Return value: (transfer none): the current preview widget, or %NULL
1884 gtk_file_chooser_get_preview_widget (GtkFileChooser *chooser)
1886 GtkWidget *preview_widget;
1888 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1890 g_object_get (chooser, "preview-widget", &preview_widget, NULL);
1892 /* Horrid hack; g_object_get() refs returned objects but
1893 * that contradicts the memory management conventions
1897 g_object_unref (preview_widget);
1899 return preview_widget;
1903 * gtk_file_chooser_set_preview_widget_active:
1904 * @chooser: a #GtkFileChooser
1905 * @active: whether to display the user-specified preview widget
1907 * Sets whether the preview widget set by
1908 * gtk_file_chooser_set_preview_widget() should be shown for the
1909 * current filename. When @active is set to false, the file chooser
1910 * may display an internally generated preview of the current file
1911 * or it may display no preview at all. See
1912 * gtk_file_chooser_set_preview_widget() for more details.
1917 gtk_file_chooser_set_preview_widget_active (GtkFileChooser *chooser,
1920 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1922 g_object_set (chooser, "preview-widget-active", active, NULL);
1926 * gtk_file_chooser_get_preview_widget_active:
1927 * @chooser: a #GtkFileChooser
1929 * Gets whether the preview widget set by gtk_file_chooser_set_preview_widget()
1930 * should be shown for the current filename. See
1931 * gtk_file_chooser_set_preview_widget_active().
1933 * Return value: %TRUE if the preview widget is active for the current filename.
1938 gtk_file_chooser_get_preview_widget_active (GtkFileChooser *chooser)
1942 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1944 g_object_get (chooser, "preview-widget-active", &active, NULL);
1950 * gtk_file_chooser_set_use_preview_label:
1951 * @chooser: a #GtkFileChooser
1952 * @use_label: whether to display a stock label with the name of the previewed file
1954 * Sets whether the file chooser should display a stock label with the name of
1955 * the file that is being previewed; the default is %TRUE. Applications that
1956 * want to draw the whole preview area themselves should set this to %FALSE and
1957 * display the name themselves in their preview widget.
1959 * See also: gtk_file_chooser_set_preview_widget()
1964 gtk_file_chooser_set_use_preview_label (GtkFileChooser *chooser,
1967 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1969 g_object_set (chooser, "use-preview-label", use_label, NULL);
1973 * gtk_file_chooser_get_use_preview_label:
1974 * @chooser: a #GtkFileChooser
1976 * Gets whether a stock label should be drawn with the name of the previewed
1977 * file. See gtk_file_chooser_set_use_preview_label().
1979 * Return value: %TRUE if the file chooser is set to display a label with the
1980 * name of the previewed file, %FALSE otherwise.
1983 gtk_file_chooser_get_use_preview_label (GtkFileChooser *chooser)
1987 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1989 g_object_get (chooser, "use-preview-label", &use_label, NULL);
1995 * gtk_file_chooser_get_preview_file:
1996 * @chooser: a #GtkFileChooser
1998 * Gets the #GFile that should be previewed in a custom preview
1999 * Internal function, see gtk_file_chooser_get_preview_uri().
2001 * Return value: (transfer full): the #GFile for the file to preview,
2002 * or %NULL if no file is selected. Free with g_object_unref().
2007 gtk_file_chooser_get_preview_file (GtkFileChooser *chooser)
2009 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2011 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_preview_file (chooser);
2015 * _gtk_file_chooser_add_shortcut_folder:
2016 * @chooser: a #GtkFileChooser
2017 * @file: file for the folder to add
2018 * @error: (allow-none): location to store error, or %NULL
2020 * Adds a folder to be displayed with the shortcut folders in a file chooser.
2021 * Internal function, see gtk_file_chooser_add_shortcut_folder().
2023 * Return value: %TRUE if the folder could be added successfully, %FALSE
2029 _gtk_file_chooser_add_shortcut_folder (GtkFileChooser *chooser,
2033 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2034 g_return_val_if_fail (G_IS_FILE (file), FALSE);
2036 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_shortcut_folder (chooser, file, error);
2040 * _gtk_file_chooser_remove_shortcut_folder:
2041 * @chooser: a #GtkFileChooser
2042 * @file: file for the folder to remove
2043 * @error: (allow-none): location to store error, or %NULL
2045 * Removes a folder from the shortcut folders in a file chooser. Internal
2046 * function, see gtk_file_chooser_remove_shortcut_folder().
2048 * Return value: %TRUE if the folder could be removed successfully, %FALSE
2054 _gtk_file_chooser_remove_shortcut_folder (GtkFileChooser *chooser,
2058 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2059 g_return_val_if_fail (G_IS_FILE (file), FALSE);
2061 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_shortcut_folder (chooser, file, error);
2065 * gtk_file_chooser_get_preview_filename:
2066 * @chooser: a #GtkFileChooser
2068 * Gets the filename that should be previewed in a custom preview
2069 * widget. See gtk_file_chooser_set_preview_widget().
2071 * Return value: (type filename): the filename to preview, or %NULL if
2072 * no file is selected, or if the selected file cannot be represented
2073 * as a local filename. Free with g_free()
2078 gtk_file_chooser_get_preview_filename (GtkFileChooser *chooser)
2081 gchar *result = NULL;
2083 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2085 file = gtk_file_chooser_get_preview_file (chooser);
2088 result = g_file_get_path (file);
2089 g_object_unref (file);
2096 * gtk_file_chooser_get_preview_uri:
2097 * @chooser: a #GtkFileChooser
2099 * Gets the URI that should be previewed in a custom preview
2100 * widget. See gtk_file_chooser_set_preview_widget().
2102 * Return value: the URI for the file to preview, or %NULL if no file is
2103 * selected. Free with g_free().
2108 gtk_file_chooser_get_preview_uri (GtkFileChooser *chooser)
2111 gchar *result = NULL;
2113 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2115 file = gtk_file_chooser_get_preview_file (chooser);
2118 result = g_file_get_uri (file);
2119 g_object_unref (file);
2126 * gtk_file_chooser_set_extra_widget:
2127 * @chooser: a #GtkFileChooser
2128 * @extra_widget: widget for extra options
2130 * Sets an application-supplied widget to provide extra options to the user.
2135 gtk_file_chooser_set_extra_widget (GtkFileChooser *chooser,
2136 GtkWidget *extra_widget)
2138 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
2140 g_object_set (chooser, "extra-widget", extra_widget, NULL);
2144 * gtk_file_chooser_get_extra_widget:
2145 * @chooser: a #GtkFileChooser
2147 * Gets the current preview widget; see
2148 * gtk_file_chooser_set_extra_widget().
2150 * Return value: (transfer none): the current extra widget, or %NULL
2155 gtk_file_chooser_get_extra_widget (GtkFileChooser *chooser)
2157 GtkWidget *extra_widget;
2159 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2161 g_object_get (chooser, "extra-widget", &extra_widget, NULL);
2163 /* Horrid hack; g_object_get() refs returned objects but
2164 * that contradicts the memory management conventions
2168 g_object_unref (extra_widget);
2170 return extra_widget;
2174 * gtk_file_chooser_add_filter:
2175 * @chooser: a #GtkFileChooser
2176 * @filter: a #GtkFileFilter
2178 * Adds @filter to the list of filters that the user can select between.
2179 * When a filter is selected, only files that are passed by that
2180 * filter are displayed.
2182 * Note that the @chooser takes ownership of the filter, so you have to
2183 * ref and sink it if you want to keep a reference.
2188 gtk_file_chooser_add_filter (GtkFileChooser *chooser,
2189 GtkFileFilter *filter)
2191 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
2193 GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_filter (chooser, filter);
2197 * gtk_file_chooser_remove_filter:
2198 * @chooser: a #GtkFileChooser
2199 * @filter: a #GtkFileFilter
2201 * Removes @filter from the list of filters that the user can select between.
2206 gtk_file_chooser_remove_filter (GtkFileChooser *chooser,
2207 GtkFileFilter *filter)
2209 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
2211 GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_filter (chooser, filter);
2215 * gtk_file_chooser_list_filters:
2216 * @chooser: a #GtkFileChooser
2218 * Lists the current set of user-selectable filters; see
2219 * gtk_file_chooser_add_filter(), gtk_file_chooser_remove_filter().
2221 * Return value: (element-type GtkFileFilter) (transfer container): a
2222 * #GSList containing the current set of user selectable filters. The
2223 * contents of the list are owned by GTK+, but you must free the list
2224 * itself with g_slist_free() when you are done with it.
2229 gtk_file_chooser_list_filters (GtkFileChooser *chooser)
2231 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2233 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->list_filters (chooser);
2237 * gtk_file_chooser_set_filter:
2238 * @chooser: a #GtkFileChooser
2239 * @filter: a #GtkFileFilter
2241 * Sets the current filter; only the files that pass the
2242 * filter will be displayed. If the user-selectable list of filters
2243 * is non-empty, then the filter should be one of the filters
2244 * in that list. Setting the current filter when the list of
2245 * filters is empty is useful if you want to restrict the displayed
2246 * set of files without letting the user change it.
2251 gtk_file_chooser_set_filter (GtkFileChooser *chooser,
2252 GtkFileFilter *filter)
2254 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
2255 g_return_if_fail (GTK_IS_FILE_FILTER (filter));
2257 g_object_set (chooser, "filter", filter, NULL);
2261 * gtk_file_chooser_get_filter:
2262 * @chooser: a #GtkFileChooser
2264 * Gets the current filter; see gtk_file_chooser_set_filter().
2266 * Return value: (transfer none): the current filter, or %NULL
2271 gtk_file_chooser_get_filter (GtkFileChooser *chooser)
2273 GtkFileFilter *filter;
2275 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2277 g_object_get (chooser, "filter", &filter, NULL);
2278 /* Horrid hack; g_object_get() refs returned objects but
2279 * that contradicts the memory management conventions
2283 g_object_unref (filter);
2289 * gtk_file_chooser_add_shortcut_folder:
2290 * @chooser: a #GtkFileChooser
2291 * @folder: (type filename): filename of the folder to add
2292 * @error: (allow-none): location to store error, or %NULL
2294 * Adds a folder to be displayed with the shortcut folders in a file chooser.
2295 * Note that shortcut folders do not get saved, as they are provided by the
2296 * application. For example, you can use this to add a
2297 * "/usr/share/mydrawprogram/Clipart" folder to the volume list.
2299 * Return value: %TRUE if the folder could be added successfully, %FALSE
2300 * otherwise. In the latter case, the @error will be set as appropriate.
2305 gtk_file_chooser_add_shortcut_folder (GtkFileChooser *chooser,
2312 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2313 g_return_val_if_fail (folder != NULL, FALSE);
2315 file = g_file_new_for_path (folder);
2316 result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_shortcut_folder (chooser, file, error);
2317 g_object_unref (file);
2323 * gtk_file_chooser_remove_shortcut_folder:
2324 * @chooser: a #GtkFileChooser
2325 * @folder: (type filename): filename of the folder to remove
2326 * @error: (allow-none): location to store error, or %NULL
2328 * Removes a folder from a file chooser's list of shortcut folders.
2330 * Return value: %TRUE if the operation succeeds, %FALSE otherwise.
2331 * In the latter case, the @error will be set as appropriate.
2333 * See also: gtk_file_chooser_add_shortcut_folder()
2338 gtk_file_chooser_remove_shortcut_folder (GtkFileChooser *chooser,
2345 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2346 g_return_val_if_fail (folder != NULL, FALSE);
2348 file = g_file_new_for_path (folder);
2349 result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_shortcut_folder (chooser, file, error);
2350 g_object_unref (file);
2356 * gtk_file_chooser_list_shortcut_folders:
2357 * @chooser: a #GtkFileChooser
2359 * Queries the list of shortcut folders in the file chooser, as set by
2360 * gtk_file_chooser_add_shortcut_folder().
2362 * Return value: (element-type filename) (transfer full): A list of
2363 * folder filenames, or %NULL if there are no shortcut folders. Free
2364 * the returned list with g_slist_free(), and the filenames with
2370 gtk_file_chooser_list_shortcut_folders (GtkFileChooser *chooser)
2375 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2377 folders = _gtk_file_chooser_list_shortcut_folder_files (chooser);
2379 result = files_to_strings (folders, g_file_get_path);
2380 g_slist_foreach (folders, (GFunc) g_object_unref, NULL);
2381 g_slist_free (folders);
2387 * gtk_file_chooser_add_shortcut_folder_uri:
2388 * @chooser: a #GtkFileChooser
2389 * @uri: URI of the folder to add
2390 * @error: (allow-none): location to store error, or %NULL
2392 * Adds a folder URI to be displayed with the shortcut folders in a file
2393 * chooser. Note that shortcut folders do not get saved, as they are provided
2394 * by the application. For example, you can use this to add a
2395 * "file:///usr/share/mydrawprogram/Clipart" folder to the volume list.
2397 * Return value: %TRUE if the folder could be added successfully, %FALSE
2398 * otherwise. In the latter case, the @error will be set as appropriate.
2403 gtk_file_chooser_add_shortcut_folder_uri (GtkFileChooser *chooser,
2410 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2411 g_return_val_if_fail (uri != NULL, FALSE);
2413 file = g_file_new_for_uri (uri);
2414 result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_shortcut_folder (chooser, file, error);
2415 g_object_unref (file);
2421 * gtk_file_chooser_remove_shortcut_folder_uri:
2422 * @chooser: a #GtkFileChooser
2423 * @uri: URI of the folder to remove
2424 * @error: (allow-none): location to store error, or %NULL
2426 * Removes a folder URI from a file chooser's list of shortcut folders.
2428 * Return value: %TRUE if the operation succeeds, %FALSE otherwise.
2429 * In the latter case, the @error will be set as appropriate.
2431 * See also: gtk_file_chooser_add_shortcut_folder_uri()
2436 gtk_file_chooser_remove_shortcut_folder_uri (GtkFileChooser *chooser,
2443 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2444 g_return_val_if_fail (uri != NULL, FALSE);
2446 file = g_file_new_for_uri (uri);
2447 result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_shortcut_folder (chooser, file, error);
2448 g_object_unref (file);
2454 * gtk_file_chooser_list_shortcut_folder_uris:
2455 * @chooser: a #GtkFileChooser
2457 * Queries the list of shortcut folders in the file chooser, as set by
2458 * gtk_file_chooser_add_shortcut_folder_uri().
2460 * Return value: (element-type utf8) (transfer full): A list of folder
2461 * URIs, or %NULL if there are no shortcut folders. Free the returned
2462 * list with g_slist_free(), and the URIs with g_free().
2467 gtk_file_chooser_list_shortcut_folder_uris (GtkFileChooser *chooser)
2472 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2474 folders = _gtk_file_chooser_list_shortcut_folder_files (chooser);
2476 result = files_to_strings (folders, g_file_get_uri);
2477 g_slist_foreach (folders, (GFunc) g_object_unref, NULL);
2478 g_slist_free (folders);
2484 _gtk_file_chooser_list_shortcut_folder_files (GtkFileChooser *chooser)
2486 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2488 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->list_shortcut_folders (chooser);
2492 * gtk_file_chooser_set_show_hidden:
2493 * @chooser: a #GtkFileChooser
2494 * @show_hidden: %TRUE if hidden files and folders should be displayed.
2496 * Sets whether hidden files and folders are displayed in the file selector.
2501 gtk_file_chooser_set_show_hidden (GtkFileChooser *chooser,
2502 gboolean show_hidden)
2504 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
2506 g_object_set (chooser, "show-hidden", show_hidden, NULL);
2510 * gtk_file_chooser_get_show_hidden:
2511 * @chooser: a #GtkFileChooser
2513 * Gets whether hidden files and folders are displayed in the file selector.
2514 * See gtk_file_chooser_set_show_hidden().
2516 * Return value: %TRUE if hidden files and folders are displayed.
2521 gtk_file_chooser_get_show_hidden (GtkFileChooser *chooser)
2523 gboolean show_hidden;
2525 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2527 g_object_get (chooser, "show-hidden", &show_hidden, NULL);
2533 * gtk_file_chooser_set_do_overwrite_confirmation:
2534 * @chooser: a #GtkFileChooser
2535 * @do_overwrite_confirmation: whether to confirm overwriting in save mode
2537 * Sets whether a file chooser in %GTK_FILE_CHOOSER_ACTION_SAVE mode will present
2538 * a confirmation dialog if the user types a file name that already exists. This
2539 * is %FALSE by default.
2541 * Regardless of this setting, the @chooser will emit the
2542 * #GtkFileChooser::confirm-overwrite signal when appropriate.
2544 * If all you need is the stock confirmation dialog, set this property to %TRUE.
2545 * You can override the way confirmation is done by actually handling the
2546 * #GtkFileChooser::confirm-overwrite signal; please refer to its documentation
2552 gtk_file_chooser_set_do_overwrite_confirmation (GtkFileChooser *chooser,
2553 gboolean do_overwrite_confirmation)
2555 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
2557 g_object_set (chooser, "do-overwrite-confirmation", do_overwrite_confirmation, NULL);
2561 * gtk_file_chooser_get_do_overwrite_confirmation:
2562 * @chooser: a #GtkFileChooser
2564 * Queries whether a file chooser is set to confirm for overwriting when the user
2565 * types a file name that already exists.
2567 * Return value: %TRUE if the file chooser will present a confirmation dialog;
2573 gtk_file_chooser_get_do_overwrite_confirmation (GtkFileChooser *chooser)
2575 gboolean do_overwrite_confirmation;
2577 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2579 g_object_get (chooser, "do-overwrite-confirmation", &do_overwrite_confirmation, NULL);
2581 return do_overwrite_confirmation;