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"
32 * SECTION:gtkfilechooser
33 * @Short_description: File chooser interface used by GtkFileChooserWidget and GtkFileChooserDialog
34 * @Title: GtkFileChooser
35 * @See_also: #GtkFileChooserDialog, #GtkFileChooserWidget, #GtkFileChooserButton
37 * #GtkFileChooser is an interface that can be implemented by file
38 * selection widgets. In GTK+, the main objects that implement this
39 * interface are #GtkFileChooserWidget, #GtkFileChooserDialog, and
40 * #GtkFileChooserButton. You do not need to write an object that
41 * implements the #GtkFileChooser interface unless you are trying to
42 * adapt an existing file selector to expose a standard programming
45 * #GtkFileChooser allows for shortcuts to various places in the filesystem.
46 * In the default implementation these are displayed in the left pane. It
47 * may be a bit confusing at first taht these shortcuts come from various
48 * sources and in various flavours, so lets explain the terminology here:
51 * <term>Bookmarks</term>
53 * are created by the user, by dragging folders from the
54 * right pane to the left pane, or by using the "Add". Bookmarks
55 * can be renamed and deleted by the user.
59 * <term>Shortcuts</term>
61 * can be provided by the application or by the underlying filesystem
62 * abstraction (e.g. both the gnome-vfs and the Windows filesystems
63 * provide "Desktop" shortcuts). Shortcuts cannot be modified by the
68 * <term>Volumes</term>
70 * are provided by the underlying filesystem abstraction. They are
71 * the "roots" of the filesystem.
76 * <refsect2 id="gtkfilechooser-encodings">
77 * <title>File Names and Encodings</title>
78 * When the user is finished selecting files in a
79 * #GtkFileChooser, your program can get the selected names
80 * either as filenames or as URIs. For URIs, the normal escaping
81 * rules are applied if the URI contains non-ASCII characters.
82 * However, filenames are <emphasis>always</emphasis> returned in
83 * the character set specified by the
84 * <envar>G_FILENAME_ENCODING</envar> environment variable.
85 * Please see the Glib documentation for more details about this
88 * This means that while you can pass the result of
89 * gtk_file_chooser_get_filename() to
90 * <function>open(2)</function> or
91 * <function>fopen(3)</function>, you may not be able to
92 * directly set it as the text of a #GtkLabel widget unless you
93 * convert it first to UTF-8, which all GTK+ widgets expect.
94 * You should use g_filename_to_utf8() to convert filenames
95 * into strings that can be passed to GTK+ widgets.
98 * <refsect2 id="gtkfilechooser-preview">
99 * <title>Adding a Preview Widget</title>
101 * You can add a custom preview widget to a file chooser and then
102 * get notification about when the preview needs to be updated.
103 * To install a preview widget, use
104 * gtk_file_chooser_set_preview_widget(). Then, connect to the
105 * #GtkFileChooser::update-preview signal to get notified when
106 * you need to update the contents of the preview.
109 * Your callback should use
110 * gtk_file_chooser_get_preview_filename() to see what needs
111 * previewing. Once you have generated the preview for the
112 * corresponding file, you must call
113 * gtk_file_chooser_set_preview_widget_active() with a boolean
114 * flag that indicates whether your callback could successfully
115 * generate a preview.
117 * <example id="example-gtkfilechooser-preview">
118 * <title>Sample Usage</title>
125 * preview = gtk_image_new (<!-- -->);
127 * gtk_file_chooser_set_preview_widget (my_file_chooser, preview);
128 * g_signal_connect (my_file_chooser, "update-preview",
129 * G_CALLBACK (update_preview_cb), preview);
133 * update_preview_cb (GtkFileChooser *file_chooser, gpointer data)
135 * GtkWidget *preview;
138 * gboolean have_preview;
140 * preview = GTK_WIDGET (data);
141 * filename = gtk_file_chooser_get_preview_filename (file_chooser);
143 * pixbuf = gdk_pixbuf_new_from_file_at_size (filename, 128, 128, NULL);
144 * have_preview = (pixbuf != NULL);
147 * gtk_image_set_from_pixbuf (GTK_IMAGE (preview), pixbuf);
149 * g_object_unref (pixbuf);
151 * gtk_file_chooser_set_preview_widget_active (file_chooser, have_preview);
156 * <refsect2 id="gtkfilechooser-extra">
157 * <title>Adding Extra Widgets</title>
159 * You can add extra widgets to a file chooser to provide options
160 * that are not present in the default design. For example, you
161 * can add a toggle button to give the user the option to open a
162 * file in read-only mode. You can use
163 * gtk_file_chooser_set_extra_widget() to insert additional
164 * widgets in a file chooser.
166 * <example id="example-gtkfilechooser-extra">
167 * <title>Sample Usage</title>
174 * toggle = gtk_check_button_new_with_label ("Open file read-only");
175 * gtk_widget_show (toggle);
176 * gtk_file_chooser_set_extra_widget (my_file_chooser, toggle);
181 * If you want to set more than one extra widget in the file
182 * chooser, you can a container such as a #GtkVBox or a #GtkTable
183 * and include your widgets in it. Then, set the container as
184 * the whole extra widget.
187 * <refsect2 id="gtkfilechooser-key-bindings">
188 * <title>Key Bindings</title>
190 * Internally, GTK+ implements a file chooser's graphical user
191 * interface with the private
192 * <classname>GtkFileChooserDefaultClass</classname>. This
193 * widget has several <link linkend="gtk-Bindings">key
194 * bindings</link> and their associated signals. This section
195 * describes the available key binding signals.
197 * <example id="gtkfilechooser-key-binding-example">
198 * <title>GtkFileChooser key binding example</title>
200 * The default keys that activate the key-binding signals in
201 * <classname>GtkFileChooserDefaultClass</classname> are as
208 * <entry>Signal name</entry>
209 * <entry>Default key combinations</entry>
212 * <entry>location-popup</entry>
214 * <keycombo><keycap>Control</keycap><keycap>L</keycap></keycombo> (empty path);
215 * <keycap>/</keycap> (path of "/")
217 * Both the individual <keycap>/</keycap> key and the
218 * numeric keypad's "divide" key are supported.
220 * <keycap>~</keycap> (path of "~")
224 * <entry>up-folder</entry>
226 * <keycombo><keycap>Alt</keycap><keycap>Up</keycap></keycombo>
228 * Both the individual Up key and the numeric
229 * keypad's Up key are supported.
232 * <keycap>Backspace</keycap>
236 * <entry>down-folder</entry>
237 * <entry><keycombo><keycap>Alt</keycap><keycap>Down</keycap></keycombo></entry>
240 * <entry>home-folder</entry>
241 * <entry><keycombo><keycap>Alt</keycap><keycap>Home</keycap></keycombo></entry>
244 * <entry>desktop-folder</entry>
245 * <entry><keycombo><keycap>Alt</keycap><keycap>D</keycap></keycombo></entry>
248 * <entry>quick-bookmark</entry>
249 * <entry><keycombo><keycap>Alt</keycap><keycap>1</keycap></keycombo> through <keycombo><keycap>Alt</keycap><keycap>0</keycap></keycombo></entry>
255 * You can change these defaults to something else. For
256 * example, to add a <keycap>Shift</keycap> modifier to a few
257 * of the default bindings, you can include the following
258 * fragment in your <filename>.gtkrc-2.0</filename> file:
261 * binding "my-own-gtkfilechooser-bindings" {
262 * bind "<Alt><Shift>Up" {
265 * bind "<Alt><Shift>Down" {
268 * bind "<Alt><Shift>Home" {
273 * class "GtkFileChooserDefault" binding "my-own-gtkfilechooser-bindings"
276 * <refsect3 id="GtkFileChooserDefault-location-popup">
277 * <title>The "GtkFileChooserDefault::location-popup" signal</title>
279 * void user_function (GtkFileChooserDefault *chooser,
281 * <link linkend="gpointer">gpointer</link> user_data);
284 * This is used to make the file chooser show a "Location"
285 * dialog which the user can use to manually type the name of
286 * the file he wishes to select. The
287 * <parameter>path</parameter> argument is a string that gets
288 * put in the text entry for the file name. By default this is bound to
289 * <keycombo><keycap>Control</keycap><keycap>L</keycap></keycombo>
290 * with a <parameter>path</parameter> string of "" (the empty
291 * string). It is also bound to <keycap>/</keycap> with a
292 * <parameter>path</parameter> string of "<literal>/</literal>"
293 * (a slash): this lets you type <keycap>/</keycap> and
294 * immediately type a path name. On Unix systems, this is bound to
295 * <keycap>~</keycap> (tilde) with a <parameter>path</parameter> string
296 * of "~" itself for access to home directories.
298 * <variablelist role="params">
300 * <term><parameter>chooser</parameter> :</term>
303 * the object which received the signal.
308 * <term><parameter>path</parameter> :</term>
311 * default contents for the text entry for the file name
316 * <term><parameter>user_data</parameter> :</term>
319 * user data set when the signal handler was connected.
325 * You can create your own bindings for the
326 * #GtkFileChooserDefault::location-popup signal with custom
327 * <parameter>path</parameter> strings, and have a crude form
328 * of easily-to-type bookmarks. For example, say you access
329 * the path <filename>/home/username/misc</filename> very
330 * frequently. You could then create an <keycombo>
331 * <keycap>Alt</keycap> <keycap>M</keycap> </keycombo>
332 * shortcut by including the following in your
333 * <filename>.gtkrc-2.0</filename>:
335 * binding "misc-shortcut" {
336 * bind "<Alt>M" {
337 * "location-popup" ("/home/username/misc")
341 * class "GtkFileChooserDefault" binding "misc-shortcut"
345 * <refsect3 id="GtkFileChooserDefault-up-folder">
346 * <title>The "GtkFileChooserDefault::up-folder" signal</title>
348 * void user_function (GtkFileChooserDefault *chooser,
349 * <link linkend="gpointer">gpointer</link> user_data);
352 * This is used to make the file chooser go to the parent of
353 * the current folder in the file hierarchy. By default this
354 * is bound to <keycap>Backspace</keycap> and
355 * <keycombo><keycap>Alt</keycap><keycap>Up</keycap></keycombo>
356 * (the Up key in the numeric keypad also works).
358 * <variablelist role="params">
360 * <term><parameter>chooser</parameter> :</term>
363 * the object which received the signal.
368 * <term><parameter>user_data</parameter> :</term>
371 * user data set when the signal handler was connected.
377 * <refsect3 id="GtkFileChooserDefault-down-folder">
378 * <title>The "GtkFileChooserDefault::down-folder" signal</title>
380 * void user_function (GtkFileChooserDefault *chooser,
381 * <link linkend="gpointer">gpointer</link> user_data);
384 * This is used to make the file chooser go to a child of the
385 * current folder in the file hierarchy. The subfolder that
386 * will be used is displayed in the path bar widget of the file
387 * chooser. For example, if the path bar is showing
388 * "/foo/<emphasis>bar/</emphasis>baz", then this will cause
389 * the file chooser to switch to the "baz" subfolder. By
390 * default this is bound to
391 * <keycombo><keycap>Alt</keycap><keycap>Down</keycap></keycombo>
392 * (the Down key in the numeric keypad also works).
394 * <variablelist role="params">
396 * <term><parameter>chooser</parameter> :</term>
399 * the object which received the signal.
404 * <term><parameter>user_data</parameter> :</term>
407 * user data set when the signal handler was connected.
413 * <refsect3 id="GtkFileChooserDefault-home-folder">
414 * <title>The "GtkFileChooserDefault::home-folder" signal</title>
416 * void user_function (GtkFileChooserDefault *chooser,
417 * <link linkend="gpointer">gpointer</link> user_data);
420 * This is used to make the file chooser show the user's home
421 * folder in the file list. By default this is bound to
422 * <keycombo><keycap>Alt</keycap><keycap>Home</keycap></keycombo>
423 * (the Home key in the numeric keypad also works).
425 * <variablelist role="params">
427 * <term><parameter>chooser</parameter> :</term>
430 * the object which received the signal.
435 * <term><parameter>user_data</parameter> :</term>
438 * user data set when the signal handler was connected.
444 * <refsect3 id="GtkFileChooserDefault-desktop-folder">
445 * <title>The "GtkFileChooserDefault::desktop-folder" signal</title>
447 * void user_function (GtkFileChooserDefault *chooser,
448 * <link linkend="gpointer">gpointer</link> user_data);
451 * This is used to make the file chooser show the user's Desktop
452 * folder in the file list. By default this is bound to
453 * <keycombo><keycap>Alt</keycap><keycap>D</keycap></keycombo>.
455 * <variablelist role="params">
457 * <term><parameter>chooser</parameter> :</term>
460 * the object which received the signal.
465 * <term><parameter>user_data</parameter> :</term>
468 * user data set when the signal handler was connected.
474 * <refsect3 id="GtkFileChooserDefault-quick-bookmark">
475 * <title>The "GtkFileChooserDefault::quick-bookmark" signal</title>
477 * void user_function (GtkFileChooserDefault *chooser,
478 * gint bookmark_index,
479 * <link linkend="gpointer">gpointer</link> user_data);
482 * This is used to make the file chooser switch to the bookmark
483 * specified in the <parameter>bookmark_index</parameter> parameter.
484 * For example, if you have three bookmarks, you can pass 0, 1, 2 to
485 * this signal to switch to each of them, respectively. By default this is bound to
486 * <keycombo><keycap>Alt</keycap><keycap>1</keycap></keycombo>,
487 * <keycombo><keycap>Alt</keycap><keycap>2</keycap></keycombo>,
489 * <keycombo><keycap>Alt</keycap><keycap>0</keycap></keycombo>. Note
490 * that in the default binding,
491 * that <keycombo><keycap>Alt</keycap><keycap>1</keycap></keycombo> is
492 * actually defined to switch to the bookmark at index 0, and so on
494 * <keycombo><keycap>Alt</keycap><keycap>0</keycap></keycombo> is
495 * defined to switch to the bookmark at index 10.
497 * <variablelist role="params">
499 * <term><parameter>chooser</parameter> :</term>
502 * the object which received the signal.
508 * <term><parameter>bookmark_indes</parameter> :</term>
510 * <term><parameter>bookmark_index</parameter> :</term>
511 >>>>>>> native-layout-incubator
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 static void gtk_file_chooser_class_init (gpointer g_iface);
535 gtk_file_chooser_get_type (void)
537 static GType file_chooser_type = 0;
539 if (!file_chooser_type)
541 file_chooser_type = g_type_register_static_simple (G_TYPE_INTERFACE,
542 I_("GtkFileChooser"),
543 sizeof (GtkFileChooserIface),
544 (GClassInitFunc) gtk_file_chooser_class_init,
547 g_type_interface_add_prerequisite (file_chooser_type, GTK_TYPE_WIDGET);
550 return file_chooser_type;
554 confirm_overwrite_accumulator (GSignalInvocationHint *ihint,
556 const GValue *handler_return,
559 gboolean continue_emission;
560 GtkFileChooserConfirmation conf;
562 conf = g_value_get_enum (handler_return);
563 g_value_set_enum (return_accu, conf);
564 continue_emission = (conf == GTK_FILE_CHOOSER_CONFIRMATION_CONFIRM);
566 return continue_emission;
570 gtk_file_chooser_class_init (gpointer g_iface)
572 GType iface_type = G_TYPE_FROM_INTERFACE (g_iface);
575 * GtkFileChooser::current-folder-changed
576 * @chooser: the object which received the signal.
578 * This signal is emitted when the current folder in a #GtkFileChooser
579 * changes. This can happen due to the user performing some action that
580 * changes folders, such as selecting a bookmark or visiting a folder on the
581 * file list. It can also happen as a result of calling a function to
582 * explicitly change the current folder in a file chooser.
584 * Normally you do not need to connect to this signal, unless you need to keep
585 * track of which folder a file chooser is showing.
587 * See also: gtk_file_chooser_set_current_folder(),
588 * gtk_file_chooser_get_current_folder(),
589 * gtk_file_chooser_set_current_folder_uri(),
590 * gtk_file_chooser_get_current_folder_uri().
592 g_signal_new (I_("current-folder-changed"),
595 G_STRUCT_OFFSET (GtkFileChooserIface, current_folder_changed),
597 g_cclosure_marshal_VOID__VOID,
601 * GtkFileChooser::selection-changed
602 * @chooser: the object which received the signal.
604 * This signal is emitted when there is a change in the set of selected files
605 * in a #GtkFileChooser. This can happen when the user modifies the selection
606 * with the mouse or the keyboard, or when explicitly calling functions to
607 * change the selection.
609 * Normally you do not need to connect to this signal, as it is easier to wait
610 * for the file chooser to finish running, and then to get the list of
611 * selected files using the functions mentioned below.
613 * See also: gtk_file_chooser_select_filename(),
614 * gtk_file_chooser_unselect_filename(), gtk_file_chooser_get_filename(),
615 * gtk_file_chooser_get_filenames(), gtk_file_chooser_select_uri(),
616 * gtk_file_chooser_unselect_uri(), gtk_file_chooser_get_uri(),
617 * gtk_file_chooser_get_uris().
619 g_signal_new (I_("selection-changed"),
622 G_STRUCT_OFFSET (GtkFileChooserIface, selection_changed),
624 g_cclosure_marshal_VOID__VOID,
628 * GtkFileChooser::update-preview
629 * @chooser: the object which received the signal.
631 * This signal is emitted when the preview in a file chooser should be
632 * regenerated. For example, this can happen when the currently selected file
633 * changes. You should use this signal if you want your file chooser to have
636 * Once you have installed a preview widget with
637 * gtk_file_chooser_set_preview_widget(), you should update it when this
638 * signal is emitted. You can use the functions
639 * gtk_file_chooser_get_preview_filename() or
640 * gtk_file_chooser_get_preview_uri() to get the name of the file to preview.
641 * Your widget may not be able to preview all kinds of files; your callback
642 * must call gtk_file_chooser_set_preview_widget_active() to inform the file
643 * chooser about whether the preview was generated successfully or not.
645 * Please see the example code in <xref linkend="gtkfilechooser-preview"/>.
647 * See also: gtk_file_chooser_set_preview_widget(),
648 * gtk_file_chooser_set_preview_widget_active(),
649 * gtk_file_chooser_set_use_preview_label(),
650 * gtk_file_chooser_get_preview_filename(),
651 * gtk_file_chooser_get_preview_uri().
653 g_signal_new (I_("update-preview"),
656 G_STRUCT_OFFSET (GtkFileChooserIface, update_preview),
658 g_cclosure_marshal_VOID__VOID,
662 * GtkFileChooser::file-activated
663 * @chooser: the object which received the signal.
665 * This signal is emitted when the user "activates" a file in the file
666 * chooser. This can happen by double-clicking on a file in the file list, or
667 * by pressing <keycap>Enter</keycap>.
669 * Normally you do not need to connect to this signal. It is used internally
670 * by #GtkFileChooserDialog to know when to activate the default button in the
673 * See also: gtk_file_chooser_get_filename(),
674 * gtk_file_chooser_get_filenames(), gtk_file_chooser_get_uri(),
675 * gtk_file_chooser_get_uris().
677 g_signal_new (I_("file-activated"),
680 G_STRUCT_OFFSET (GtkFileChooserIface, file_activated),
682 g_cclosure_marshal_VOID__VOID,
686 * GtkFileChooser::confirm-overwrite:
687 * @chooser: the object which received the signal.
689 * This signal gets emitted whenever it is appropriate to present a
690 * confirmation dialog when the user has selected a file name that
691 * already exists. The signal only gets emitted when the file
692 * chooser is in %GTK_FILE_CHOOSER_ACTION_SAVE mode.
694 * Most applications just need to turn on the
695 * #GtkFileChooser:do-overwrite-confirmation property (or call the
696 * gtk_file_chooser_set_do_overwrite_confirmation() function), and
697 * they will automatically get a stock confirmation dialog.
698 * Applications which need to customize this behavior should do
699 * that, and also connect to the #GtkFileChooser::confirm-overwrite
702 * A signal handler for this signal must return a
703 * #GtkFileChooserConfirmation value, which indicates the action to
704 * take. If the handler determines that the user wants to select a
705 * different filename, it should return
706 * %GTK_FILE_CHOOSER_CONFIRMATION_SELECT_AGAIN. If it determines
707 * that the user is satisfied with his choice of file name, it
708 * should return %GTK_FILE_CHOOSER_CONFIRMATION_ACCEPT_FILENAME.
709 * On the other hand, if it determines that the stock confirmation
710 * dialog should be used, it should return
711 * %GTK_FILE_CHOOSER_CONFIRMATION_CONFIRM. The following example
713 * <example id="gtkfilechooser-confirmation">
714 * <title>Custom confirmation</title>
716 * static GtkFileChooserConfirmation
717 * confirm_overwrite_callback (GtkFileChooser *chooser, gpointer data)
721 * uri = gtk_file_chooser_get_uri (chooser);
723 * if (is_uri_read_only (uri))
725 * if (user_wants_to_replace_read_only_file (uri))
726 * return GTK_FILE_CHOOSER_CONFIRMATION_ACCEPT_FILENAME;
728 * return GTK_FILE_CHOOSER_CONFIRMATION_SELECT_AGAIN;
730 * return GTK_FILE_CHOOSER_CONFIRMATION_CONFIRM; // fall back to the default dialog
735 * chooser = gtk_file_chooser_dialog_new (...);
737 * gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), TRUE);
738 * g_signal_connect (chooser, "confirm-overwrite",
739 * G_CALLBACK (confirm_overwrite_callback), NULL);
741 * if (gtk_dialog_run (chooser) == GTK_RESPONSE_ACCEPT)
742 * save_to_file (gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (chooser));
744 * gtk_widget_destroy (chooser);
748 * Returns: a #GtkFileChooserConfirmation value that indicates which
749 * action to take after emitting the signal.
753 g_signal_new (I_("confirm-overwrite"),
756 G_STRUCT_OFFSET (GtkFileChooserIface, confirm_overwrite),
757 confirm_overwrite_accumulator, NULL,
758 _gtk_marshal_ENUM__VOID,
759 GTK_TYPE_FILE_CHOOSER_CONFIRMATION, 0);
761 g_object_interface_install_property (g_iface,
762 g_param_spec_enum ("action",
764 P_("The type of operation that the file selector is performing"),
765 GTK_TYPE_FILE_CHOOSER_ACTION,
766 GTK_FILE_CHOOSER_ACTION_OPEN,
767 GTK_PARAM_READWRITE));
768 g_object_interface_install_property (g_iface,
769 g_param_spec_string ("file-system-backend",
770 P_("File System Backend"),
771 P_("Name of file system backend to use"),
773 GTK_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
774 g_object_interface_install_property (g_iface,
775 g_param_spec_object ("filter",
777 P_("The current filter for selecting which files are displayed"),
778 GTK_TYPE_FILE_FILTER,
779 GTK_PARAM_READWRITE));
780 g_object_interface_install_property (g_iface,
781 g_param_spec_boolean ("local-only",
783 P_("Whether the selected file(s) should be limited to local file: URLs"),
785 GTK_PARAM_READWRITE));
786 g_object_interface_install_property (g_iface,
787 g_param_spec_object ("preview-widget",
788 P_("Preview widget"),
789 P_("Application supplied widget for custom previews."),
791 GTK_PARAM_READWRITE));
792 g_object_interface_install_property (g_iface,
793 g_param_spec_boolean ("preview-widget-active",
794 P_("Preview Widget Active"),
795 P_("Whether the application supplied widget for custom previews should be shown."),
797 GTK_PARAM_READWRITE));
798 g_object_interface_install_property (g_iface,
799 g_param_spec_boolean ("use-preview-label",
800 P_("Use Preview Label"),
801 P_("Whether to display a stock label with the name of the previewed file."),
803 GTK_PARAM_READWRITE));
804 g_object_interface_install_property (g_iface,
805 g_param_spec_object ("extra-widget",
807 P_("Application supplied widget for extra options."),
809 GTK_PARAM_READWRITE));
810 g_object_interface_install_property (g_iface,
811 g_param_spec_boolean ("select-multiple",
812 P_("Select Multiple"),
813 P_("Whether to allow multiple files to be selected"),
815 GTK_PARAM_READWRITE));
817 g_object_interface_install_property (g_iface,
818 g_param_spec_boolean ("show-hidden",
820 P_("Whether the hidden files and folders should be displayed"),
822 GTK_PARAM_READWRITE));
825 * GtkFileChooser:do-overwrite-confirmation:
827 * Whether a file chooser in %GTK_FILE_CHOOSER_ACTION_SAVE mode
828 * will present an overwrite confirmation dialog if the user
829 * selects a file name that already exists.
833 g_object_interface_install_property (g_iface,
834 g_param_spec_boolean ("do-overwrite-confirmation",
835 P_("Do overwrite confirmation"),
836 P_("Whether a file chooser in save mode "
837 "will present an overwrite confirmation dialog "
840 GTK_PARAM_READWRITE));
843 * GtkFileChooser:create-folders:
845 * Whether a file chooser not in %GTK_FILE_CHOOSER_ACTION_OPEN mode
846 * will offer the user to create new folders.
850 g_object_interface_install_property (g_iface,
851 g_param_spec_boolean ("create-folders",
852 P_("Allow folders creation"),
853 P_("Whether a file chooser not in open mode "
854 "will offer the user to create new folders."),
856 GTK_PARAM_READWRITE));
860 * gtk_file_chooser_error_quark:
862 * Registers an error quark for #GtkFileChooser if necessary.
864 * Return value: The error quark used for #GtkFileChooser errors.
869 gtk_file_chooser_error_quark (void)
871 return g_quark_from_static_string ("gtk-file-chooser-error-quark");
875 * gtk_file_chooser_set_action:
876 * @chooser: a #GtkFileChooser
877 * @action: the action that the file selector is performing
879 * Sets the type of operation that the chooser is performing; the
880 * user interface is adapted to suit the selected action. For example,
881 * an option to create a new folder might be shown if the action is
882 * %GTK_FILE_CHOOSER_ACTION_SAVE but not if the action is
883 * %GTK_FILE_CHOOSER_ACTION_OPEN.
888 gtk_file_chooser_set_action (GtkFileChooser *chooser,
889 GtkFileChooserAction action)
891 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
893 g_object_set (chooser, "action", action, NULL);
897 * gtk_file_chooser_get_action:
898 * @chooser: a #GtkFileChooser
900 * Gets the type of operation that the file chooser is performing; see
901 * gtk_file_chooser_set_action().
903 * Return value: the action that the file selector is performing
908 gtk_file_chooser_get_action (GtkFileChooser *chooser)
910 GtkFileChooserAction action;
912 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
914 g_object_get (chooser, "action", &action, NULL);
920 * gtk_file_chooser_set_local_only:
921 * @chooser: a #GtkFileChooser
922 * @local_only: %TRUE if only local files can be selected
924 * Sets whether only local files can be selected in the
925 * file selector. If @local_only is %TRUE (the default),
926 * then the selected file are files are guaranteed to be
927 * accessible through the operating systems native file
928 * file system and therefore the application only
929 * needs to worry about the filename functions in
930 * #GtkFileChooser, like gtk_file_chooser_get_filename(),
931 * rather than the URI functions like
932 * gtk_file_chooser_get_uri(),
937 gtk_file_chooser_set_local_only (GtkFileChooser *chooser,
940 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
942 g_object_set (chooser, "local-only", local_only, NULL);
946 * gtk_file_chooser_get_local_only:
947 * @chooser: a #GtkFileChoosre
949 * Gets whether only local files can be selected in the
950 * file selector. See gtk_file_chooser_set_local_only()
952 * Return value: %TRUE if only local files can be selected.
957 gtk_file_chooser_get_local_only (GtkFileChooser *chooser)
961 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
963 g_object_get (chooser, "local-only", &local_only, NULL);
969 * gtk_file_chooser_set_select_multiple:
970 * @chooser: a #GtkFileChooser
971 * @select_multiple: %TRUE if multiple files can be selected.
973 * Sets whether multiple files can be selected in the file selector. This is
974 * only relevant if the action is set to be %GTK_FILE_CHOOSER_ACTION_OPEN or
975 * %GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER.
980 gtk_file_chooser_set_select_multiple (GtkFileChooser *chooser,
981 gboolean select_multiple)
983 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
985 g_object_set (chooser, "select-multiple", select_multiple, NULL);
989 * gtk_file_chooser_get_select_multiple:
990 * @chooser: a #GtkFileChooser
992 * Gets whether multiple files can be selected in the file
993 * selector. See gtk_file_chooser_set_select_multiple().
995 * Return value: %TRUE if multiple files can be selected.
1000 gtk_file_chooser_get_select_multiple (GtkFileChooser *chooser)
1002 gboolean select_multiple;
1004 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1006 g_object_get (chooser, "select-multiple", &select_multiple, NULL);
1008 return select_multiple;
1012 * gtk_file_chooser_set_create_folders:
1013 * @chooser: a #GtkFileChooser
1014 * @create_folders: %TRUE if the New Folder button should be displayed
1016 * Sets whether file choser will offer to create new folders.
1017 * This is only relevant if the action is not set to be
1018 * %GTK_FILE_CHOOSER_ACTION_OPEN.
1023 gtk_file_chooser_set_create_folders (GtkFileChooser *chooser,
1024 gboolean create_folders)
1026 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1028 g_object_set (chooser, "create-folders", create_folders, NULL);
1032 * gtk_file_chooser_get_create_folders:
1033 * @chooser: a #GtkFileChooser
1035 * Gets whether file choser will offer to create new folders.
1036 * See gtk_file_chooser_set_create_folders().
1038 * Return value: %TRUE if the New Folder button should be displayed.
1043 gtk_file_chooser_get_create_folders (GtkFileChooser *chooser)
1045 gboolean create_folders;
1047 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1049 g_object_get (chooser, "create-folders", &create_folders, NULL);
1051 return create_folders;
1055 * gtk_file_chooser_get_filename:
1056 * @chooser: a #GtkFileChooser
1058 * Gets the filename for the currently selected file in
1059 * the file selector. If multiple files are selected,
1060 * one of the filenames will be returned at random.
1062 * If the file chooser is in folder mode, this function returns the selected
1065 * Return value: The currently selected filename, or %NULL
1066 * if no file is selected, or the selected file can't
1067 * be represented with a local filename. Free with g_free().
1072 gtk_file_chooser_get_filename (GtkFileChooser *chooser)
1075 gchar *result = NULL;
1077 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1079 file = gtk_file_chooser_get_file (chooser);
1083 result = g_file_get_path (file);
1084 g_object_unref (file);
1091 * gtk_file_chooser_set_filename:
1092 * @chooser: a #GtkFileChooser
1093 * @filename: the filename to set as current
1095 * Sets @filename as the current filename for the file chooser, by changing
1096 * to the file's parent folder and actually selecting the file in list. If
1097 * the @chooser is in %GTK_FILE_CHOOSER_ACTION_SAVE mode, the file's base name
1098 * will also appear in the dialog's file name entry.
1100 * If the file name isn't in the current folder of @chooser, then the current
1101 * folder of @chooser will be changed to the folder containing @filename. This
1102 * is equivalent to a sequence of gtk_file_chooser_unselect_all() followed by
1103 * gtk_file_chooser_select_filename().
1105 * Note that the file must exist, or nothing will be done except
1106 * for the directory change.
1108 * If you are implementing a <guimenuitem>File/Save As...</guimenuitem> dialog,
1109 * you should use this function if you already have a file name to which the
1110 * user may save; for example, when the user opens an existing file and then
1111 * does <guimenuitem>File/Save As...</guimenuitem> on it. If you don't have
1112 * a file name already — for example, if the user just created a new
1113 * file and is saving it for the first time, do not call this function.
1114 * Instead, use something similar to this:
1116 * if (document_is_new)
1118 * /* the user just created a new document */
1119 * gtk_file_chooser_set_current_folder (chooser, default_folder_for_saving);
1120 * gtk_file_chooser_set_current_name (chooser, "Untitled document");
1124 * /* the user edited an existing document */
1125 * gtk_file_chooser_set_filename (chooser, existing_filename);
1129 * Return value: %TRUE if both the folder could be changed and the file was
1130 * selected successfully, %FALSE otherwise.
1135 gtk_file_chooser_set_filename (GtkFileChooser *chooser,
1136 const gchar *filename)
1138 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1140 gtk_file_chooser_unselect_all (chooser);
1141 return gtk_file_chooser_select_filename (chooser, filename);
1145 * gtk_file_chooser_select_filename:
1146 * @chooser: a #GtkFileChooser
1147 * @filename: the filename to select
1149 * Selects a filename. If the file name isn't in the current
1150 * folder of @chooser, then the current folder of @chooser will
1151 * be changed to the folder containing @filename.
1153 * Return value: %TRUE if both the folder could be changed and the file was
1154 * selected successfully, %FALSE otherwise.
1159 gtk_file_chooser_select_filename (GtkFileChooser *chooser,
1160 const gchar *filename)
1165 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1166 g_return_val_if_fail (filename != NULL, FALSE);
1168 file = g_file_new_for_path (filename);
1169 result = gtk_file_chooser_select_file (chooser, file, NULL);
1170 g_object_unref (file);
1176 * gtk_file_chooser_unselect_filename:
1177 * @chooser: a #GtkFileChooser
1178 * @filename: the filename to unselect
1180 * Unselects a currently selected filename. If the filename
1181 * is not in the current directory, does not exist, or
1182 * is otherwise not currently selected, does nothing.
1187 gtk_file_chooser_unselect_filename (GtkFileChooser *chooser,
1188 const char *filename)
1192 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1193 g_return_if_fail (filename != NULL);
1195 file = g_file_new_for_path (filename);
1196 gtk_file_chooser_unselect_file (chooser, file);
1197 g_object_unref (file);
1200 /* Converts a list of GFile* to a list of strings using the specified function */
1202 files_to_strings (GSList *files,
1203 gchar * (*convert_func) (GFile *file))
1209 for (; files; files = files->next)
1215 string = (* convert_func) (file);
1218 strings = g_slist_prepend (strings, string);
1221 return g_slist_reverse (strings);
1225 * gtk_file_chooser_get_filenames:
1226 * @chooser: a #GtkFileChooser
1228 * Lists all the selected files and subfolders in the current folder of
1229 * @chooser. The returned names are full absolute paths. If files in the current
1230 * folder cannot be represented as local filenames they will be ignored. (See
1231 * gtk_file_chooser_get_uris())
1233 * Return value: (element-type utf8) (transfer full): a #GSList containing the filenames of all selected
1234 * files and subfolders in the current folder. Free the returned list
1235 * with g_slist_free(), and the filenames with g_free().
1240 gtk_file_chooser_get_filenames (GtkFileChooser *chooser)
1242 GSList *files, *result;
1244 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1246 files = gtk_file_chooser_get_files (chooser);
1248 result = files_to_strings (files, g_file_get_path);
1249 g_slist_foreach (files, (GFunc) g_object_unref, NULL);
1250 g_slist_free (files);
1256 * gtk_file_chooser_set_current_folder:
1257 * @chooser: a #GtkFileChooser
1258 * @filename: the full path of the new current folder
1260 * Sets the current folder for @chooser from a local filename.
1261 * The user will be shown the full contents of the current folder,
1262 * plus user interface elements for navigating to other folders.
1264 * Return value: %TRUE if the folder could be changed successfully, %FALSE
1270 gtk_file_chooser_set_current_folder (GtkFileChooser *chooser,
1271 const gchar *filename)
1276 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1277 g_return_val_if_fail (filename != NULL, FALSE);
1279 file = g_file_new_for_path (filename);
1280 result = gtk_file_chooser_set_current_folder_file (chooser, file, NULL);
1281 g_object_unref (file);
1287 * gtk_file_chooser_get_current_folder:
1288 * @chooser: a #GtkFileChooser
1290 * Gets the current folder of @chooser as a local filename.
1291 * See gtk_file_chooser_set_current_folder().
1293 * Note that this is the folder that the file chooser is currently displaying
1294 * (e.g. "/home/username/Documents"), which is <emphasis>not the same</emphasis>
1295 * as the currently-selected folder if the chooser is in
1296 * %GTK_FILE_CHOOSER_SELECT_FOLDER mode
1297 * (e.g. "/home/username/Documents/selected-folder/". To get the
1298 * currently-selected folder in that mode, use gtk_file_chooser_get_uri() as the
1299 * usual way to get the selection.
1301 * Return value: the full path of the current folder, or %NULL if the current
1302 * path cannot be represented as a local filename. Free with g_free(). This
1303 * function will also return %NULL if the file chooser was unable to load the
1304 * last folder that was requested from it; for example, as would be for calling
1305 * gtk_file_chooser_set_current_folder() on a nonexistent folder.
1310 gtk_file_chooser_get_current_folder (GtkFileChooser *chooser)
1315 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1317 file = gtk_file_chooser_get_current_folder_file (chooser);
1321 filename = g_file_get_path (file);
1322 g_object_unref (file);
1328 * gtk_file_chooser_set_current_name:
1329 * @chooser: a #GtkFileChooser
1330 * @name: the filename to use, as a UTF-8 string
1332 * Sets the current name in the file selector, as if entered
1333 * by the user. Note that the name passed in here is a UTF-8
1334 * string rather than a filename. This function is meant for
1335 * such uses as a suggested name in a "Save As..." dialog.
1337 * If you want to preselect a particular existing file, you should use
1338 * gtk_file_chooser_set_filename() or gtk_file_chooser_set_uri() instead.
1339 * Please see the documentation for those functions for an example of using
1340 * gtk_file_chooser_set_current_name() as well.
1345 gtk_file_chooser_set_current_name (GtkFileChooser *chooser,
1348 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1349 g_return_if_fail (name != NULL);
1351 GTK_FILE_CHOOSER_GET_IFACE (chooser)->set_current_name (chooser, name);
1355 * gtk_file_chooser_get_uri:
1356 * @chooser: a #GtkFileChooser
1358 * Gets the URI for the currently selected file in
1359 * the file selector. If multiple files are selected,
1360 * one of the filenames will be returned at random.
1362 * If the file chooser is in folder mode, this function returns the selected
1365 * Return value: The currently selected URI, or %NULL
1366 * if no file is selected. Free with g_free()
1371 gtk_file_chooser_get_uri (GtkFileChooser *chooser)
1374 gchar *result = NULL;
1376 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1378 file = gtk_file_chooser_get_file (chooser);
1381 result = g_file_get_uri (file);
1382 g_object_unref (file);
1389 * gtk_file_chooser_set_uri:
1390 * @chooser: a #GtkFileChooser
1391 * @uri: the URI to set as current
1393 * Sets the file referred to by @uri as the current file for the file chooser,
1394 * by changing to the URI's parent folder and actually selecting the URI in the
1395 * list. If the @chooser is %GTK_FILE_CHOOSER_ACTION_SAVE mode, the URI's base
1396 * name will also appear in the dialog's file name entry.
1398 * If the URI isn't in the current folder of @chooser, then the current folder
1399 * of @chooser will be changed to the folder containing @uri. This is equivalent
1400 * to a sequence of gtk_file_chooser_unselect_all() followed by
1401 * gtk_file_chooser_select_uri().
1403 * Note that the URI must exist, or nothing will be done except for the
1405 * If you are implementing a <guimenuitem>File/Save As...</guimenuitem> dialog,
1406 * you should use this function if you already have a file name to which the
1407 * user may save; for example, when the user opens an existing file and then
1408 * does <guimenuitem>File/Save As...</guimenuitem> on it. If you don't have
1409 * a file name already — for example, if the user just created a new
1410 * file and is saving it for the first time, do not call this function.
1411 * Instead, use something similar to this:
1413 * if (document_is_new)
1415 * /* the user just created a new document */
1416 * gtk_file_chooser_set_current_folder_uri (chooser, default_folder_for_saving);
1417 * gtk_file_chooser_set_current_name (chooser, "Untitled document");
1421 * /* the user edited an existing document */
1422 * gtk_file_chooser_set_uri (chooser, existing_uri);
1426 * Return value: %TRUE if both the folder could be changed and the URI was
1427 * selected successfully, %FALSE otherwise.
1432 gtk_file_chooser_set_uri (GtkFileChooser *chooser,
1435 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1437 gtk_file_chooser_unselect_all (chooser);
1438 return gtk_file_chooser_select_uri (chooser, uri);
1442 * gtk_file_chooser_select_uri:
1443 * @chooser: a #GtkFileChooser
1444 * @uri: the URI to select
1446 * Selects the file to by @uri. If the URI doesn't refer to a
1447 * file in the current folder of @chooser, then the current folder of
1448 * @chooser will be changed to the folder containing @filename.
1450 * Return value: %TRUE if both the folder could be changed and the URI was
1451 * selected successfully, %FALSE otherwise.
1456 gtk_file_chooser_select_uri (GtkFileChooser *chooser,
1462 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1463 g_return_val_if_fail (uri != NULL, FALSE);
1465 file = g_file_new_for_uri (uri);
1466 result = gtk_file_chooser_select_file (chooser, file, NULL);
1467 g_object_unref (file);
1473 * gtk_file_chooser_unselect_uri:
1474 * @chooser: a #GtkFileChooser
1475 * @uri: the URI to unselect
1477 * Unselects the file referred to by @uri. If the file
1478 * is not in the current directory, does not exist, or
1479 * is otherwise not currently selected, does nothing.
1484 gtk_file_chooser_unselect_uri (GtkFileChooser *chooser,
1489 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1490 g_return_if_fail (uri != NULL);
1492 file = g_file_new_for_uri (uri);
1493 gtk_file_chooser_unselect_file (chooser, file);
1494 g_object_unref (file);
1498 * gtk_file_chooser_select_all:
1499 * @chooser: a #GtkFileChooser
1501 * Selects all the files in the current folder of a file chooser.
1506 gtk_file_chooser_select_all (GtkFileChooser *chooser)
1508 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1510 GTK_FILE_CHOOSER_GET_IFACE (chooser)->select_all (chooser);
1514 * gtk_file_chooser_unselect_all:
1515 * @chooser: a #GtkFileChooser
1517 * Unselects all the files in the current folder of a file chooser.
1522 gtk_file_chooser_unselect_all (GtkFileChooser *chooser)
1525 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1527 GTK_FILE_CHOOSER_GET_IFACE (chooser)->unselect_all (chooser);
1531 * gtk_file_chooser_get_uris:
1532 * @chooser: a #GtkFileChooser
1534 * Lists all the selected files and subfolders in the current folder of
1535 * @chooser. The returned names are full absolute URIs.
1537 * Return value: (element-type utf8) (transfer full): a #GSList containing the URIs of all selected
1538 * files and subfolders in the current folder. Free the returned list
1539 * with g_slist_free(), and the filenames with g_free().
1544 gtk_file_chooser_get_uris (GtkFileChooser *chooser)
1546 GSList *files, *result;
1548 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1550 files = gtk_file_chooser_get_files (chooser);
1552 result = files_to_strings (files, g_file_get_uri);
1553 g_slist_foreach (files, (GFunc) g_object_unref, NULL);
1554 g_slist_free (files);
1560 * gtk_file_chooser_set_current_folder_uri:
1561 * @chooser: a #GtkFileChooser
1562 * @uri: the URI for the new current folder
1564 * Sets the current folder for @chooser from an URI.
1565 * The user will be shown the full contents of the current folder,
1566 * plus user interface elements for navigating to other folders.
1568 * Return value: %TRUE if the folder could be changed successfully, %FALSE
1574 gtk_file_chooser_set_current_folder_uri (GtkFileChooser *chooser,
1580 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1581 g_return_val_if_fail (uri != NULL, FALSE);
1583 file = g_file_new_for_uri (uri);
1584 result = gtk_file_chooser_set_current_folder_file (chooser, file, NULL);
1585 g_object_unref (file);
1591 * gtk_file_chooser_get_current_folder_uri:
1592 * @chooser: a #GtkFileChooser
1594 * Gets the current folder of @chooser as an URI.
1595 * See gtk_file_chooser_set_current_folder_uri().
1597 * Note that this is the folder that the file chooser is currently displaying
1598 * (e.g. "file:///home/username/Documents"), which is <emphasis>not the same</emphasis>
1599 * as the currently-selected folder if the chooser is in
1600 * %GTK_FILE_CHOOSER_SELECT_FOLDER mode
1601 * (e.g. "file:///home/username/Documents/selected-folder/". To get the
1602 * currently-selected folder in that mode, use gtk_file_chooser_get_uri() as the
1603 * usual way to get the selection.
1605 * Return value: the URI for the current folder. Free with g_free(). This
1606 * function will also return %NULL if the file chooser was unable to load the
1607 * last folder that was requested from it; for example, as would be for calling
1608 * gtk_file_chooser_set_current_folder_uri() on a nonexistent folder.
1613 gtk_file_chooser_get_current_folder_uri (GtkFileChooser *chooser)
1618 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1620 file = gtk_file_chooser_get_current_folder_file (chooser);
1624 uri = g_file_get_uri (file);
1625 g_object_unref (file);
1631 * gtk_file_chooser_set_current_folder_file:
1632 * @chooser: a #GtkFileChooser
1633 * @file: the #GFile for the new folder
1634 * @error: (allow-none): location to store error, or %NULL.
1636 * Sets the current folder for @chooser from a #GFile.
1637 * Internal function, see gtk_file_chooser_set_current_folder_uri().
1639 * Return value: %TRUE if the folder could be changed successfully, %FALSE
1645 gtk_file_chooser_set_current_folder_file (GtkFileChooser *chooser,
1649 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1650 g_return_val_if_fail (G_IS_FILE (file), FALSE);
1651 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
1653 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->set_current_folder (chooser, file, error);
1657 * gtk_file_chooser_get_current_folder_file:
1658 * @chooser: a #GtkFileChooser
1660 * Gets the current folder of @chooser as #GFile.
1661 * See gtk_file_chooser_get_current_folder_uri().
1663 * Return value: the #GFile for the current folder.
1668 gtk_file_chooser_get_current_folder_file (GtkFileChooser *chooser)
1670 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1672 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_current_folder (chooser);
1676 * gtk_file_chooser_select_file:
1677 * @chooser: a #GtkFileChooser
1678 * @file: the file to select
1679 * @error: (allow-none): location to store error, or %NULL
1681 * Selects the file referred to by @file. An internal function. See
1682 * _gtk_file_chooser_select_uri().
1684 * Return value: %TRUE if both the folder could be changed and the path was
1685 * selected successfully, %FALSE otherwise.
1690 gtk_file_chooser_select_file (GtkFileChooser *chooser,
1694 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1695 g_return_val_if_fail (G_IS_FILE (file), FALSE);
1696 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
1698 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->select_file (chooser, file, error);
1702 * gtk_file_chooser_unselect_file:
1703 * @chooser: a #GtkFileChooser
1706 * Unselects the file referred to by @file. If the file is not in the current
1707 * directory, does not exist, or is otherwise not currently selected, does nothing.
1712 gtk_file_chooser_unselect_file (GtkFileChooser *chooser,
1715 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1716 g_return_if_fail (G_IS_FILE (file));
1718 GTK_FILE_CHOOSER_GET_IFACE (chooser)->unselect_file (chooser, file);
1722 * gtk_file_chooser_get_files:
1723 * @chooser: a #GtkFileChooser
1725 * Lists all the selected files and subfolders in the current folder of @chooser
1726 * as #GFile. An internal function, see gtk_file_chooser_get_uris().
1728 * Return value: (element-type utf8) (transfer full): a #GSList containing a #GFile for each selected
1729 * file and subfolder in the current folder. Free the returned list
1730 * with g_slist_free(), and the files with g_object_unref().
1735 gtk_file_chooser_get_files (GtkFileChooser *chooser)
1737 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1739 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_files (chooser);
1743 * gtk_file_chooser_set_file:
1744 * @chooser: a #GtkFileChooser
1745 * @file: the #GFile to set as current
1746 * @error: (allow-none): location to store the error, or %NULL to ignore errors.
1748 * Sets @file as the current filename for the file chooser, by changing
1749 * to the file's parent folder and actually selecting the file in list. If
1750 * the @chooser is in %GTK_FILE_CHOOSER_ACTION_SAVE mode, the file's base name
1751 * will also appear in the dialog's file name entry.
1753 * If the file name isn't in the current folder of @chooser, then the current
1754 * folder of @chooser will be changed to the folder containing @filename. This
1755 * is equivalent to a sequence of gtk_file_chooser_unselect_all() followed by
1756 * gtk_file_chooser_select_filename().
1758 * Note that the file must exist, or nothing will be done except
1759 * for the directory change.
1761 * If you are implementing a <guimenuitem>File/Save As...</guimenuitem> dialog,
1762 * you should use this function if you already have a file name to which the
1763 * user may save; for example, when the user opens an existing file and then
1764 * does <guimenuitem>File/Save As...</guimenuitem> on it. If you don't have
1765 * a file name already — for example, if the user just created a new
1766 * file and is saving it for the first time, do not call this function.
1767 * Instead, use something similar to this:
1769 * if (document_is_new)
1771 * /* the user just created a new document */
1772 * gtk_file_chooser_set_current_folder_file (chooser, default_file_for_saving);
1773 * gtk_file_chooser_set_current_name (chooser, "Untitled document");
1777 * /* the user edited an existing document */
1778 * gtk_file_chooser_set_file (chooser, existing_file);
1782 * Return value: %TRUE if both the folder could be changed and the file was
1783 * selected successfully, %FALSE otherwise.
1788 gtk_file_chooser_set_file (GtkFileChooser *chooser,
1792 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1793 g_return_val_if_fail (G_IS_FILE (file), FALSE);
1794 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
1796 gtk_file_chooser_unselect_all (chooser);
1797 return gtk_file_chooser_select_file (chooser, file, error);
1801 * gtk_file_chooser_get_file:
1802 * @chooser: a #GtkFileChooser
1804 * Gets the #GFile for the currently selected file in
1805 * the file selector. If multiple files are selected,
1806 * one of the files will be returned at random.
1808 * If the file chooser is in folder mode, this function returns the selected
1811 * Returns: a selected #GFile. You own the returned file; use
1812 * g_object_unref() to release it.
1817 gtk_file_chooser_get_file (GtkFileChooser *chooser)
1820 GFile *result = NULL;
1822 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1824 list = gtk_file_chooser_get_files (chooser);
1827 result = list->data;
1828 list = g_slist_delete_link (list, list);
1830 g_slist_foreach (list, (GFunc) g_object_unref, NULL);
1831 g_slist_free (list);
1838 * _gtk_file_chooser_get_file_system:
1839 * @chooser: a #GtkFileChooser
1841 * Gets the #GtkFileSystem of @chooser; this is an internal
1842 * implementation detail, used for conversion between paths
1843 * and filenames and URIs.
1845 * Return value: the file system for @chooser.
1850 _gtk_file_chooser_get_file_system (GtkFileChooser *chooser)
1852 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1854 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_file_system (chooser);
1860 * gtk_file_chooser_set_preview_widget:
1861 * @chooser: a #GtkFileChooser
1862 * @preview_widget: widget for displaying preview.
1864 * Sets an application-supplied widget to use to display a custom preview
1865 * of the currently selected file. To implement a preview, after setting the
1866 * preview widget, you connect to the #GtkFileChooser::update-preview
1867 * signal, and call gtk_file_chooser_get_preview_filename() or
1868 * gtk_file_chooser_get_preview_uri() on each change. If you can
1869 * display a preview of the new file, update your widget and
1870 * set the preview active using gtk_file_chooser_set_preview_widget_active().
1871 * Otherwise, set the preview inactive.
1873 * When there is no application-supplied preview widget, or the
1874 * application-supplied preview widget is not active, the file chooser
1875 * may display an internally generated preview of the current file or
1876 * it may display no preview at all.
1881 gtk_file_chooser_set_preview_widget (GtkFileChooser *chooser,
1882 GtkWidget *preview_widget)
1884 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1886 g_object_set (chooser, "preview-widget", preview_widget, NULL);
1890 * gtk_file_chooser_get_preview_widget:
1891 * @chooser: a #GtkFileChooser
1893 * Gets the current preview widget; see
1894 * gtk_file_chooser_set_preview_widget().
1896 * Return value: the current preview widget, or %NULL
1901 gtk_file_chooser_get_preview_widget (GtkFileChooser *chooser)
1903 GtkWidget *preview_widget;
1905 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1907 g_object_get (chooser, "preview-widget", &preview_widget, NULL);
1909 /* Horrid hack; g_object_get() refs returned objects but
1910 * that contradicts the memory management conventions
1914 g_object_unref (preview_widget);
1916 return preview_widget;
1920 * gtk_file_chooser_set_preview_widget_active:
1921 * @chooser: a #GtkFileChooser
1922 * @active: whether to display the user-specified preview widget
1924 * Sets whether the preview widget set by
1925 * gtk_file_chooser_set_preview_widget() should be shown for the
1926 * current filename. When @active is set to false, the file chooser
1927 * may display an internally generated preview of the current file
1928 * or it may display no preview at all. See
1929 * gtk_file_chooser_set_preview_widget() for more details.
1934 gtk_file_chooser_set_preview_widget_active (GtkFileChooser *chooser,
1937 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1939 g_object_set (chooser, "preview-widget-active", active, NULL);
1943 * gtk_file_chooser_get_preview_widget_active:
1944 * @chooser: a #GtkFileChooser
1946 * Gets whether the preview widget set by gtk_file_chooser_set_preview_widget()
1947 * should be shown for the current filename. See
1948 * gtk_file_chooser_set_preview_widget_active().
1950 * Return value: %TRUE if the preview widget is active for the current filename.
1955 gtk_file_chooser_get_preview_widget_active (GtkFileChooser *chooser)
1959 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1961 g_object_get (chooser, "preview-widget-active", &active, NULL);
1967 * gtk_file_chooser_set_use_preview_label:
1968 * @chooser: a #GtkFileChooser
1969 * @use_label: whether to display a stock label with the name of the previewed file
1971 * Sets whether the file chooser should display a stock label with the name of
1972 * the file that is being previewed; the default is %TRUE. Applications that
1973 * want to draw the whole preview area themselves should set this to %FALSE and
1974 * display the name themselves in their preview widget.
1976 * See also: gtk_file_chooser_set_preview_widget()
1981 gtk_file_chooser_set_use_preview_label (GtkFileChooser *chooser,
1984 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1986 g_object_set (chooser, "use-preview-label", use_label, NULL);
1990 * gtk_file_chooser_get_use_preview_label:
1991 * @chooser: a #GtkFileChooser
1993 * Gets whether a stock label should be drawn with the name of the previewed
1994 * file. See gtk_file_chooser_set_use_preview_label().
1996 * Return value: %TRUE if the file chooser is set to display a label with the
1997 * name of the previewed file, %FALSE otherwise.
2000 gtk_file_chooser_get_use_preview_label (GtkFileChooser *chooser)
2004 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2006 g_object_get (chooser, "use-preview-label", &use_label, NULL);
2012 * gtk_file_chooser_get_preview_file:
2013 * @chooser: a #GtkFileChooser
2015 * Gets the #GFile that should be previewed in a custom preview
2016 * Internal function, see gtk_file_chooser_get_preview_uri().
2018 * Return value: the #GFile for the file to preview, or %NULL if no file
2019 * is selected. Free with g_object_unref().
2024 gtk_file_chooser_get_preview_file (GtkFileChooser *chooser)
2026 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2028 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_preview_file (chooser);
2032 * _gtk_file_chooser_add_shortcut_folder:
2033 * @chooser: a #GtkFileChooser
2034 * @file: file for the folder to add
2035 * @error: (allow-none): location to store error, or %NULL
2037 * Adds a folder to be displayed with the shortcut folders in a file chooser.
2038 * Internal function, see gtk_file_chooser_add_shortcut_folder().
2040 * Return value: %TRUE if the folder could be added successfully, %FALSE
2046 _gtk_file_chooser_add_shortcut_folder (GtkFileChooser *chooser,
2050 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2051 g_return_val_if_fail (G_IS_FILE (file), FALSE);
2053 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_shortcut_folder (chooser, file, error);
2057 * _gtk_file_chooser_remove_shortcut_folder:
2058 * @chooser: a #GtkFileChooser
2059 * @file: file for the folder to remove
2060 * @error: (allow-none): location to store error, or %NULL
2062 * Removes a folder from the shortcut folders in a file chooser. Internal
2063 * function, see gtk_file_chooser_remove_shortcut_folder().
2065 * Return value: %TRUE if the folder could be removed successfully, %FALSE
2071 _gtk_file_chooser_remove_shortcut_folder (GtkFileChooser *chooser,
2075 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2076 g_return_val_if_fail (G_IS_FILE (file), FALSE);
2078 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_shortcut_folder (chooser, file, error);
2082 * gtk_file_chooser_get_preview_filename:
2083 * @chooser: a #GtkFileChooser
2085 * Gets the filename that should be previewed in a custom preview
2086 * widget. See gtk_file_chooser_set_preview_widget().
2088 * Return value: the filename to preview, or %NULL if no file
2089 * is selected, or if the selected file cannot be represented
2090 * as a local filename. Free with g_free()
2095 gtk_file_chooser_get_preview_filename (GtkFileChooser *chooser)
2098 gchar *result = NULL;
2100 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2102 file = gtk_file_chooser_get_preview_file (chooser);
2105 result = g_file_get_path (file);
2106 g_object_unref (file);
2113 * gtk_file_chooser_get_preview_uri:
2114 * @chooser: a #GtkFileChooser
2116 * Gets the URI that should be previewed in a custom preview
2117 * widget. See gtk_file_chooser_set_preview_widget().
2119 * Return value: the URI for the file to preview, or %NULL if no file is
2120 * selected. Free with g_free().
2125 gtk_file_chooser_get_preview_uri (GtkFileChooser *chooser)
2128 gchar *result = NULL;
2130 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2132 file = gtk_file_chooser_get_preview_file (chooser);
2135 result = g_file_get_uri (file);
2136 g_object_unref (file);
2143 * gtk_file_chooser_set_extra_widget:
2144 * @chooser: a #GtkFileChooser
2145 * @extra_widget: widget for extra options
2147 * Sets an application-supplied widget to provide extra options to the user.
2152 gtk_file_chooser_set_extra_widget (GtkFileChooser *chooser,
2153 GtkWidget *extra_widget)
2155 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
2157 g_object_set (chooser, "extra-widget", extra_widget, NULL);
2161 * gtk_file_chooser_get_extra_widget:
2162 * @chooser: a #GtkFileChooser
2164 * Gets the current preview widget; see
2165 * gtk_file_chooser_set_extra_widget().
2167 * Return value: the current extra widget, or %NULL
2172 gtk_file_chooser_get_extra_widget (GtkFileChooser *chooser)
2174 GtkWidget *extra_widget;
2176 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2178 g_object_get (chooser, "extra-widget", &extra_widget, NULL);
2180 /* Horrid hack; g_object_get() refs returned objects but
2181 * that contradicts the memory management conventions
2185 g_object_unref (extra_widget);
2187 return extra_widget;
2191 * gtk_file_chooser_add_filter:
2192 * @chooser: a #GtkFileChooser
2193 * @filter: a #GtkFileFilter
2195 * Adds @filter to the list of filters that the user can select between.
2196 * When a filter is selected, only files that are passed by that
2197 * filter are displayed.
2199 * Note that the @chooser takes ownership of the filter, so you have to
2200 * ref and sink it if you want to keep a reference.
2205 gtk_file_chooser_add_filter (GtkFileChooser *chooser,
2206 GtkFileFilter *filter)
2208 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
2210 GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_filter (chooser, filter);
2214 * gtk_file_chooser_remove_filter:
2215 * @chooser: a #GtkFileChooser
2216 * @filter: a #GtkFileFilter
2218 * Removes @filter from the list of filters that the user can select between.
2223 gtk_file_chooser_remove_filter (GtkFileChooser *chooser,
2224 GtkFileFilter *filter)
2226 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
2228 GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_filter (chooser, filter);
2232 * gtk_file_chooser_list_filters:
2233 * @chooser: a #GtkFileChooser
2235 * Lists the current set of user-selectable filters; see
2236 * gtk_file_chooser_add_filter(), gtk_file_chooser_remove_filter().
2238 * Return value: (element-type utf8) (transfer container): a #GSList containing the current set of
2239 * user selectable filters. The contents of the list are
2240 * owned by GTK+, but you must free the list itself with
2241 * g_slist_free() when you are done with it.
2246 gtk_file_chooser_list_filters (GtkFileChooser *chooser)
2248 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2250 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->list_filters (chooser);
2254 * gtk_file_chooser_set_filter:
2255 * @chooser: a #GtkFileChooser
2256 * @filter: a #GtkFileFilter
2258 * Sets the current filter; only the files that pass the
2259 * filter will be displayed. If the user-selectable list of filters
2260 * is non-empty, then the filter should be one of the filters
2261 * in that list. Setting the current filter when the list of
2262 * filters is empty is useful if you want to restrict the displayed
2263 * set of files without letting the user change it.
2268 gtk_file_chooser_set_filter (GtkFileChooser *chooser,
2269 GtkFileFilter *filter)
2271 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
2272 g_return_if_fail (GTK_IS_FILE_FILTER (filter));
2274 g_object_set (chooser, "filter", filter, NULL);
2278 * gtk_file_chooser_get_filter:
2279 * @chooser: a #GtkFileChooser
2281 * Gets the current filter; see gtk_file_chooser_set_filter().
2283 * Return value: the current filter, or %NULL
2288 gtk_file_chooser_get_filter (GtkFileChooser *chooser)
2290 GtkFileFilter *filter;
2292 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2294 g_object_get (chooser, "filter", &filter, NULL);
2295 /* Horrid hack; g_object_get() refs returned objects but
2296 * that contradicts the memory management conventions
2300 g_object_unref (filter);
2306 * gtk_file_chooser_add_shortcut_folder:
2307 * @chooser: a #GtkFileChooser
2308 * @folder: filename of the folder to add
2309 * @error: (allow-none): location to store error, or %NULL
2311 * Adds a folder to be displayed with the shortcut folders in a file chooser.
2312 * Note that shortcut folders do not get saved, as they are provided by the
2313 * application. For example, you can use this to add a
2314 * "/usr/share/mydrawprogram/Clipart" folder to the volume list.
2316 * Return value: %TRUE if the folder could be added successfully, %FALSE
2317 * otherwise. In the latter case, the @error will be set as appropriate.
2322 gtk_file_chooser_add_shortcut_folder (GtkFileChooser *chooser,
2329 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2330 g_return_val_if_fail (folder != NULL, FALSE);
2332 file = g_file_new_for_path (folder);
2333 result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_shortcut_folder (chooser, file, error);
2334 g_object_unref (file);
2340 * gtk_file_chooser_remove_shortcut_folder:
2341 * @chooser: a #GtkFileChooser
2342 * @folder: filename of the folder to remove
2343 * @error: (allow-none): location to store error, or %NULL
2345 * Removes a folder from a file chooser's list of shortcut folders.
2347 * Return value: %TRUE if the operation succeeds, %FALSE otherwise.
2348 * In the latter case, the @error will be set as appropriate.
2350 * See also: gtk_file_chooser_add_shortcut_folder()
2355 gtk_file_chooser_remove_shortcut_folder (GtkFileChooser *chooser,
2362 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2363 g_return_val_if_fail (folder != NULL, FALSE);
2365 file = g_file_new_for_path (folder);
2366 result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_shortcut_folder (chooser, file, error);
2367 g_object_unref (file);
2373 * gtk_file_chooser_list_shortcut_folders:
2374 * @chooser: a #GtkFileChooser
2376 * Queries the list of shortcut folders in the file chooser, as set by
2377 * gtk_file_chooser_add_shortcut_folder().
2379 * Return value: (element-type utf8) (transfer full): A list of folder filenames, or %NULL if there are no shortcut
2380 * folders. Free the returned list with g_slist_free(), and the filenames with
2386 gtk_file_chooser_list_shortcut_folders (GtkFileChooser *chooser)
2391 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2393 folders = _gtk_file_chooser_list_shortcut_folder_files (chooser);
2395 result = files_to_strings (folders, g_file_get_path);
2396 g_slist_foreach (folders, (GFunc) g_object_unref, NULL);
2397 g_slist_free (folders);
2403 * gtk_file_chooser_add_shortcut_folder_uri:
2404 * @chooser: a #GtkFileChooser
2405 * @uri: URI of the folder to add
2406 * @error: (allow-none): location to store error, or %NULL
2408 * Adds a folder URI to be displayed with the shortcut folders in a file
2409 * chooser. Note that shortcut folders do not get saved, as they are provided
2410 * by the application. For example, you can use this to add a
2411 * "file:///usr/share/mydrawprogram/Clipart" folder to the volume list.
2413 * Return value: %TRUE if the folder could be added successfully, %FALSE
2414 * otherwise. In the latter case, the @error will be set as appropriate.
2419 gtk_file_chooser_add_shortcut_folder_uri (GtkFileChooser *chooser,
2426 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2427 g_return_val_if_fail (uri != NULL, FALSE);
2429 file = g_file_new_for_uri (uri);
2430 result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_shortcut_folder (chooser, file, error);
2431 g_object_unref (file);
2437 * gtk_file_chooser_remove_shortcut_folder_uri:
2438 * @chooser: a #GtkFileChooser
2439 * @uri: URI of the folder to remove
2440 * @error: (allow-none): location to store error, or %NULL
2442 * Removes a folder URI from a file chooser's list of shortcut folders.
2444 * Return value: %TRUE if the operation succeeds, %FALSE otherwise.
2445 * In the latter case, the @error will be set as appropriate.
2447 * See also: gtk_file_chooser_add_shortcut_folder_uri()
2452 gtk_file_chooser_remove_shortcut_folder_uri (GtkFileChooser *chooser,
2459 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2460 g_return_val_if_fail (uri != NULL, FALSE);
2462 file = g_file_new_for_uri (uri);
2463 result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_shortcut_folder (chooser, file, error);
2464 g_object_unref (file);
2470 * gtk_file_chooser_list_shortcut_folder_uris:
2471 * @chooser: a #GtkFileChooser
2473 * Queries the list of shortcut folders in the file chooser, as set by
2474 * gtk_file_chooser_add_shortcut_folder_uri().
2476 * Return value: (element-type utf8) (transfer full): A list of folder URIs, or %NULL if there are no shortcut
2477 * folders. Free the returned list with g_slist_free(), and the URIs with
2483 gtk_file_chooser_list_shortcut_folder_uris (GtkFileChooser *chooser)
2488 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2490 folders = _gtk_file_chooser_list_shortcut_folder_files (chooser);
2492 result = files_to_strings (folders, g_file_get_uri);
2493 g_slist_foreach (folders, (GFunc) g_object_unref, NULL);
2494 g_slist_free (folders);
2500 _gtk_file_chooser_list_shortcut_folder_files (GtkFileChooser *chooser)
2502 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2504 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->list_shortcut_folders (chooser);
2508 * gtk_file_chooser_set_show_hidden:
2509 * @chooser: a #GtkFileChooser
2510 * @show_hidden: %TRUE if hidden files and folders should be displayed.
2512 * Sets whether hidden files and folders are displayed in the file selector.
2517 gtk_file_chooser_set_show_hidden (GtkFileChooser *chooser,
2518 gboolean show_hidden)
2520 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
2522 g_object_set (chooser, "show-hidden", show_hidden, NULL);
2526 * gtk_file_chooser_get_show_hidden:
2527 * @chooser: a #GtkFileChooser
2529 * Gets whether hidden files and folders are displayed in the file selector.
2530 * See gtk_file_chooser_set_show_hidden().
2532 * Return value: %TRUE if hidden files and folders are displayed.
2537 gtk_file_chooser_get_show_hidden (GtkFileChooser *chooser)
2539 gboolean show_hidden;
2541 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2543 g_object_get (chooser, "show-hidden", &show_hidden, NULL);
2549 * gtk_file_chooser_set_do_overwrite_confirmation:
2550 * @chooser: a #GtkFileChooser
2551 * @do_overwrite_confirmation: whether to confirm overwriting in save mode
2553 * Sets whether a file chooser in %GTK_FILE_CHOOSER_ACTION_SAVE mode will present
2554 * a confirmation dialog if the user types a file name that already exists. This
2555 * is %FALSE by default.
2557 * Regardless of this setting, the @chooser will emit the
2558 * #GtkFileChooser::confirm-overwrite signal when appropriate.
2560 * If all you need is the stock confirmation dialog, set this property to %TRUE.
2561 * You can override the way confirmation is done by actually handling the
2562 * #GtkFileChooser::confirm-overwrite signal; please refer to its documentation
2568 gtk_file_chooser_set_do_overwrite_confirmation (GtkFileChooser *chooser,
2569 gboolean do_overwrite_confirmation)
2571 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
2573 g_object_set (chooser, "do-overwrite-confirmation", do_overwrite_confirmation, NULL);
2577 * gtk_file_chooser_get_do_overwrite_confirmation:
2578 * @chooser: a #GtkFileChooser
2580 * Queries whether a file chooser is set to confirm for overwriting when the user
2581 * types a file name that already exists.
2583 * Return value: %TRUE if the file chooser will present a confirmation dialog;
2589 gtk_file_chooser_get_do_overwrite_confirmation (GtkFileChooser *chooser)
2591 gboolean do_overwrite_confirmation;
2593 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2595 g_object_get (chooser, "do-overwrite-confirmation", &do_overwrite_confirmation, NULL);
2597 return do_overwrite_confirmation;
2600 #if defined (G_OS_WIN32) && !defined (_WIN64)
2602 /* DLL ABI stability backward compatibility versions */
2604 #undef gtk_file_chooser_get_filename
2607 gtk_file_chooser_get_filename (GtkFileChooser *chooser)
2609 gchar *utf8_filename = gtk_file_chooser_get_filename_utf8 (chooser);
2610 gchar *retval = g_locale_from_utf8 (utf8_filename, -1, NULL, NULL, NULL);
2612 g_free (utf8_filename);
2617 #undef gtk_file_chooser_set_filename
2620 gtk_file_chooser_set_filename (GtkFileChooser *chooser,
2621 const gchar *filename)
2623 gchar *utf8_filename = g_locale_to_utf8 (filename, -1, NULL, NULL, NULL);
2624 gboolean retval = gtk_file_chooser_set_filename_utf8 (chooser, utf8_filename);
2626 g_free (utf8_filename);
2631 #undef gtk_file_chooser_select_filename
2634 gtk_file_chooser_select_filename (GtkFileChooser *chooser,
2635 const gchar *filename)
2637 gchar *utf8_filename = g_locale_to_utf8 (filename, -1, NULL, NULL, NULL);
2638 gboolean retval = gtk_file_chooser_select_filename_utf8 (chooser, utf8_filename);
2640 g_free (utf8_filename);
2645 #undef gtk_file_chooser_unselect_filename
2648 gtk_file_chooser_unselect_filename (GtkFileChooser *chooser,
2649 const char *filename)
2651 gchar *utf8_filename = g_locale_to_utf8 (filename, -1, NULL, NULL, NULL);
2653 gtk_file_chooser_unselect_filename_utf8 (chooser, utf8_filename);
2654 g_free (utf8_filename);
2657 #undef gtk_file_chooser_get_filenames
2660 gtk_file_chooser_get_filenames (GtkFileChooser *chooser)
2662 GSList *list = gtk_file_chooser_get_filenames_utf8 (chooser);
2663 GSList *rover = list;
2667 gchar *tem = (gchar *) rover->data;
2668 rover->data = g_locale_from_utf8 ((gchar *) rover->data, -1, NULL, NULL, NULL);
2670 rover = rover->next;
2676 #undef gtk_file_chooser_set_current_folder
2679 gtk_file_chooser_set_current_folder (GtkFileChooser *chooser,
2680 const gchar *filename)
2682 gchar *utf8_filename = g_locale_to_utf8 (filename, -1, NULL, NULL, NULL);
2683 gboolean retval = gtk_file_chooser_set_current_folder_utf8 (chooser, utf8_filename);
2685 g_free (utf8_filename);
2690 #undef gtk_file_chooser_get_current_folder
2693 gtk_file_chooser_get_current_folder (GtkFileChooser *chooser)
2695 gchar *utf8_folder = gtk_file_chooser_get_current_folder_utf8 (chooser);
2696 gchar *retval = g_locale_from_utf8 (utf8_folder, -1, NULL, NULL, NULL);
2698 g_free (utf8_folder);
2703 #undef gtk_file_chooser_get_preview_filename
2706 gtk_file_chooser_get_preview_filename (GtkFileChooser *chooser)
2708 char *utf8_filename = gtk_file_chooser_get_preview_filename_utf8 (chooser);
2709 char *retval = g_locale_from_utf8 (utf8_filename, -1, NULL, NULL, NULL);
2711 g_free (utf8_filename);
2716 #undef gtk_file_chooser_add_shortcut_folder
2719 gtk_file_chooser_add_shortcut_folder (GtkFileChooser *chooser,
2723 char *utf8_folder = g_locale_to_utf8 (folder, -1, NULL, NULL, NULL);
2725 gtk_file_chooser_add_shortcut_folder_utf8 (chooser, utf8_folder, error);
2727 g_free (utf8_folder);
2732 #undef gtk_file_chooser_remove_shortcut_folder
2735 gtk_file_chooser_remove_shortcut_folder (GtkFileChooser *chooser,
2739 char *utf8_folder = g_locale_to_utf8 (folder, -1, NULL, NULL, NULL);
2741 gtk_file_chooser_remove_shortcut_folder_utf8 (chooser, utf8_folder, error);
2743 g_free (utf8_folder);
2748 #undef gtk_file_chooser_list_shortcut_folders
2751 gtk_file_chooser_list_shortcut_folders (GtkFileChooser *chooser)
2753 GSList *list = gtk_file_chooser_list_shortcut_folders_utf8 (chooser);
2754 GSList *rover = list;
2758 gchar *tem = (gchar *) rover->data;
2759 rover->data = g_locale_from_utf8 ((gchar *) rover->data, -1, NULL, NULL, NULL);
2761 rover = rover->next;
2769 #define __GTK_FILE_CHOOSER_C__
2770 #include "gtkaliasdef.c"