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-3.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-3.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_object ("filter",
771 P_("The current filter for selecting which files are displayed"),
772 GTK_TYPE_FILE_FILTER,
773 GTK_PARAM_READWRITE));
774 g_object_interface_install_property (g_iface,
775 g_param_spec_boolean ("local-only",
777 P_("Whether the selected file(s) should be limited to local file: URLs"),
779 GTK_PARAM_READWRITE));
780 g_object_interface_install_property (g_iface,
781 g_param_spec_object ("preview-widget",
782 P_("Preview widget"),
783 P_("Application supplied widget for custom previews."),
785 GTK_PARAM_READWRITE));
786 g_object_interface_install_property (g_iface,
787 g_param_spec_boolean ("preview-widget-active",
788 P_("Preview Widget Active"),
789 P_("Whether the application supplied widget for custom previews should be shown."),
791 GTK_PARAM_READWRITE));
792 g_object_interface_install_property (g_iface,
793 g_param_spec_boolean ("use-preview-label",
794 P_("Use Preview Label"),
795 P_("Whether to display a stock label with the name of the previewed file."),
797 GTK_PARAM_READWRITE));
798 g_object_interface_install_property (g_iface,
799 g_param_spec_object ("extra-widget",
801 P_("Application supplied widget for extra options."),
803 GTK_PARAM_READWRITE));
804 g_object_interface_install_property (g_iface,
805 g_param_spec_boolean ("select-multiple",
806 P_("Select Multiple"),
807 P_("Whether to allow multiple files to be selected"),
809 GTK_PARAM_READWRITE));
811 g_object_interface_install_property (g_iface,
812 g_param_spec_boolean ("show-hidden",
814 P_("Whether the hidden files and folders should be displayed"),
816 GTK_PARAM_READWRITE));
819 * GtkFileChooser:do-overwrite-confirmation:
821 * Whether a file chooser in %GTK_FILE_CHOOSER_ACTION_SAVE mode
822 * will present an overwrite confirmation dialog if the user
823 * selects a file name that already exists.
827 g_object_interface_install_property (g_iface,
828 g_param_spec_boolean ("do-overwrite-confirmation",
829 P_("Do overwrite confirmation"),
830 P_("Whether a file chooser in save mode "
831 "will present an overwrite confirmation dialog "
834 GTK_PARAM_READWRITE));
837 * GtkFileChooser:create-folders:
839 * Whether a file chooser not in %GTK_FILE_CHOOSER_ACTION_OPEN mode
840 * will offer the user to create new folders.
844 g_object_interface_install_property (g_iface,
845 g_param_spec_boolean ("create-folders",
846 P_("Allow folders creation"),
847 P_("Whether a file chooser not in open mode "
848 "will offer the user to create new folders."),
850 GTK_PARAM_READWRITE));
854 * gtk_file_chooser_error_quark:
856 * Registers an error quark for #GtkFileChooser if necessary.
858 * Return value: The error quark used for #GtkFileChooser errors.
863 gtk_file_chooser_error_quark (void)
865 return g_quark_from_static_string ("gtk-file-chooser-error-quark");
869 * gtk_file_chooser_set_action:
870 * @chooser: a #GtkFileChooser
871 * @action: the action that the file selector is performing
873 * Sets the type of operation that the chooser is performing; the
874 * user interface is adapted to suit the selected action. For example,
875 * an option to create a new folder might be shown if the action is
876 * %GTK_FILE_CHOOSER_ACTION_SAVE but not if the action is
877 * %GTK_FILE_CHOOSER_ACTION_OPEN.
882 gtk_file_chooser_set_action (GtkFileChooser *chooser,
883 GtkFileChooserAction action)
885 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
887 g_object_set (chooser, "action", action, NULL);
891 * gtk_file_chooser_get_action:
892 * @chooser: a #GtkFileChooser
894 * Gets the type of operation that the file chooser is performing; see
895 * gtk_file_chooser_set_action().
897 * Return value: the action that the file selector is performing
902 gtk_file_chooser_get_action (GtkFileChooser *chooser)
904 GtkFileChooserAction action;
906 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
908 g_object_get (chooser, "action", &action, NULL);
914 * gtk_file_chooser_set_local_only:
915 * @chooser: a #GtkFileChooser
916 * @local_only: %TRUE if only local files can be selected
918 * Sets whether only local files can be selected in the
919 * file selector. If @local_only is %TRUE (the default),
920 * then the selected file are files are guaranteed to be
921 * accessible through the operating systems native file
922 * file system and therefore the application only
923 * needs to worry about the filename functions in
924 * #GtkFileChooser, like gtk_file_chooser_get_filename(),
925 * rather than the URI functions like
926 * gtk_file_chooser_get_uri(),
931 gtk_file_chooser_set_local_only (GtkFileChooser *chooser,
934 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
936 g_object_set (chooser, "local-only", local_only, NULL);
940 * gtk_file_chooser_get_local_only:
941 * @chooser: a #GtkFileChoosre
943 * Gets whether only local files can be selected in the
944 * file selector. See gtk_file_chooser_set_local_only()
946 * Return value: %TRUE if only local files can be selected.
951 gtk_file_chooser_get_local_only (GtkFileChooser *chooser)
955 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
957 g_object_get (chooser, "local-only", &local_only, NULL);
963 * gtk_file_chooser_set_select_multiple:
964 * @chooser: a #GtkFileChooser
965 * @select_multiple: %TRUE if multiple files can be selected.
967 * Sets whether multiple files can be selected in the file selector. This is
968 * only relevant if the action is set to be %GTK_FILE_CHOOSER_ACTION_OPEN or
969 * %GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER.
974 gtk_file_chooser_set_select_multiple (GtkFileChooser *chooser,
975 gboolean select_multiple)
977 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
979 g_object_set (chooser, "select-multiple", select_multiple, NULL);
983 * gtk_file_chooser_get_select_multiple:
984 * @chooser: a #GtkFileChooser
986 * Gets whether multiple files can be selected in the file
987 * selector. See gtk_file_chooser_set_select_multiple().
989 * Return value: %TRUE if multiple files can be selected.
994 gtk_file_chooser_get_select_multiple (GtkFileChooser *chooser)
996 gboolean select_multiple;
998 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1000 g_object_get (chooser, "select-multiple", &select_multiple, NULL);
1002 return select_multiple;
1006 * gtk_file_chooser_set_create_folders:
1007 * @chooser: a #GtkFileChooser
1008 * @create_folders: %TRUE if the New Folder button should be displayed
1010 * Sets whether file choser will offer to create new folders.
1011 * This is only relevant if the action is not set to be
1012 * %GTK_FILE_CHOOSER_ACTION_OPEN.
1017 gtk_file_chooser_set_create_folders (GtkFileChooser *chooser,
1018 gboolean create_folders)
1020 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1022 g_object_set (chooser, "create-folders", create_folders, NULL);
1026 * gtk_file_chooser_get_create_folders:
1027 * @chooser: a #GtkFileChooser
1029 * Gets whether file choser will offer to create new folders.
1030 * See gtk_file_chooser_set_create_folders().
1032 * Return value: %TRUE if the New Folder button should be displayed.
1037 gtk_file_chooser_get_create_folders (GtkFileChooser *chooser)
1039 gboolean create_folders;
1041 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1043 g_object_get (chooser, "create-folders", &create_folders, NULL);
1045 return create_folders;
1049 * gtk_file_chooser_get_filename:
1050 * @chooser: a #GtkFileChooser
1052 * Gets the filename for the currently selected file in
1053 * the file selector. If multiple files are selected,
1054 * one of the filenames will be returned at random.
1056 * If the file chooser is in folder mode, this function returns the selected
1059 * Return value: The currently selected filename, or %NULL
1060 * if no file is selected, or the selected file can't
1061 * be represented with a local filename. Free with g_free().
1066 gtk_file_chooser_get_filename (GtkFileChooser *chooser)
1069 gchar *result = NULL;
1071 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1073 file = gtk_file_chooser_get_file (chooser);
1077 result = g_file_get_path (file);
1078 g_object_unref (file);
1085 * gtk_file_chooser_set_filename:
1086 * @chooser: a #GtkFileChooser
1087 * @filename: the filename to set as current
1089 * Sets @filename as the current filename for the file chooser, by changing
1090 * to the file's parent folder and actually selecting the file in list. If
1091 * the @chooser is in %GTK_FILE_CHOOSER_ACTION_SAVE mode, the file's base name
1092 * will also appear in the dialog's file name entry.
1094 * If the file name isn't in the current folder of @chooser, then the current
1095 * folder of @chooser will be changed to the folder containing @filename. This
1096 * is equivalent to a sequence of gtk_file_chooser_unselect_all() followed by
1097 * gtk_file_chooser_select_filename().
1099 * Note that the file must exist, or nothing will be done except
1100 * for the directory change.
1102 * If you are implementing a <guimenuitem>File/Save As...</guimenuitem> dialog,
1103 * you should use this function if you already have a file name to which the
1104 * user may save; for example, when the user opens an existing file and then
1105 * does <guimenuitem>File/Save As...</guimenuitem> on it. If you don't have
1106 * a file name already — for example, if the user just created a new
1107 * file and is saving it for the first time, do not call this function.
1108 * Instead, use something similar to this:
1110 * if (document_is_new)
1112 * /* the user just created a new document */
1113 * gtk_file_chooser_set_current_folder (chooser, default_folder_for_saving);
1114 * gtk_file_chooser_set_current_name (chooser, "Untitled document");
1118 * /* the user edited an existing document */
1119 * gtk_file_chooser_set_filename (chooser, existing_filename);
1123 * Return value: %TRUE if both the folder could be changed and the file was
1124 * selected successfully, %FALSE otherwise.
1129 gtk_file_chooser_set_filename (GtkFileChooser *chooser,
1130 const gchar *filename)
1132 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1134 gtk_file_chooser_unselect_all (chooser);
1135 return gtk_file_chooser_select_filename (chooser, filename);
1139 * gtk_file_chooser_select_filename:
1140 * @chooser: a #GtkFileChooser
1141 * @filename: the filename to select
1143 * Selects a filename. If the file name isn't in the current
1144 * folder of @chooser, then the current folder of @chooser will
1145 * be changed to the folder containing @filename.
1147 * Return value: %TRUE if both the folder could be changed and the file was
1148 * selected successfully, %FALSE otherwise.
1153 gtk_file_chooser_select_filename (GtkFileChooser *chooser,
1154 const gchar *filename)
1159 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1160 g_return_val_if_fail (filename != NULL, FALSE);
1162 file = g_file_new_for_path (filename);
1163 result = gtk_file_chooser_select_file (chooser, file, NULL);
1164 g_object_unref (file);
1170 * gtk_file_chooser_unselect_filename:
1171 * @chooser: a #GtkFileChooser
1172 * @filename: the filename to unselect
1174 * Unselects a currently selected filename. If the filename
1175 * is not in the current directory, does not exist, or
1176 * is otherwise not currently selected, does nothing.
1181 gtk_file_chooser_unselect_filename (GtkFileChooser *chooser,
1182 const char *filename)
1186 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1187 g_return_if_fail (filename != NULL);
1189 file = g_file_new_for_path (filename);
1190 gtk_file_chooser_unselect_file (chooser, file);
1191 g_object_unref (file);
1194 /* Converts a list of GFile* to a list of strings using the specified function */
1196 files_to_strings (GSList *files,
1197 gchar * (*convert_func) (GFile *file))
1203 for (; files; files = files->next)
1209 string = (* convert_func) (file);
1212 strings = g_slist_prepend (strings, string);
1215 return g_slist_reverse (strings);
1219 * gtk_file_chooser_get_filenames:
1220 * @chooser: a #GtkFileChooser
1222 * Lists all the selected files and subfolders in the current folder of
1223 * @chooser. The returned names are full absolute paths. If files in the current
1224 * folder cannot be represented as local filenames they will be ignored. (See
1225 * gtk_file_chooser_get_uris())
1227 * Return value: (element-type utf8) (transfer full): a #GSList containing the filenames of all selected
1228 * files and subfolders in the current folder. Free the returned list
1229 * with g_slist_free(), and the filenames with g_free().
1234 gtk_file_chooser_get_filenames (GtkFileChooser *chooser)
1236 GSList *files, *result;
1238 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1240 files = gtk_file_chooser_get_files (chooser);
1242 result = files_to_strings (files, g_file_get_path);
1243 g_slist_foreach (files, (GFunc) g_object_unref, NULL);
1244 g_slist_free (files);
1250 * gtk_file_chooser_set_current_folder:
1251 * @chooser: a #GtkFileChooser
1252 * @filename: the full path of the new current folder
1254 * Sets the current folder for @chooser from a local filename.
1255 * The user will be shown the full contents of the current folder,
1256 * plus user interface elements for navigating to other folders.
1258 * Return value: %TRUE if the folder could be changed successfully, %FALSE
1264 gtk_file_chooser_set_current_folder (GtkFileChooser *chooser,
1265 const gchar *filename)
1270 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1271 g_return_val_if_fail (filename != NULL, FALSE);
1273 file = g_file_new_for_path (filename);
1274 result = gtk_file_chooser_set_current_folder_file (chooser, file, NULL);
1275 g_object_unref (file);
1281 * gtk_file_chooser_get_current_folder:
1282 * @chooser: a #GtkFileChooser
1284 * Gets the current folder of @chooser as a local filename.
1285 * See gtk_file_chooser_set_current_folder().
1287 * Note that this is the folder that the file chooser is currently displaying
1288 * (e.g. "/home/username/Documents"), which is <emphasis>not the same</emphasis>
1289 * as the currently-selected folder if the chooser is in
1290 * %GTK_FILE_CHOOSER_SELECT_FOLDER mode
1291 * (e.g. "/home/username/Documents/selected-folder/". To get the
1292 * currently-selected folder in that mode, use gtk_file_chooser_get_uri() as the
1293 * usual way to get the selection.
1295 * Return value: the full path of the current folder, or %NULL if the current
1296 * path cannot be represented as a local filename. Free with g_free(). This
1297 * function will also return %NULL if the file chooser was unable to load the
1298 * last folder that was requested from it; for example, as would be for calling
1299 * gtk_file_chooser_set_current_folder() on a nonexistent folder.
1304 gtk_file_chooser_get_current_folder (GtkFileChooser *chooser)
1309 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1311 file = gtk_file_chooser_get_current_folder_file (chooser);
1315 filename = g_file_get_path (file);
1316 g_object_unref (file);
1322 * gtk_file_chooser_set_current_name:
1323 * @chooser: a #GtkFileChooser
1324 * @name: the filename to use, as a UTF-8 string
1326 * Sets the current name in the file selector, as if entered
1327 * by the user. Note that the name passed in here is a UTF-8
1328 * string rather than a filename. This function is meant for
1329 * such uses as a suggested name in a "Save As..." dialog.
1331 * If you want to preselect a particular existing file, you should use
1332 * gtk_file_chooser_set_filename() or gtk_file_chooser_set_uri() instead.
1333 * Please see the documentation for those functions for an example of using
1334 * gtk_file_chooser_set_current_name() as well.
1339 gtk_file_chooser_set_current_name (GtkFileChooser *chooser,
1342 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1343 g_return_if_fail (name != NULL);
1345 GTK_FILE_CHOOSER_GET_IFACE (chooser)->set_current_name (chooser, name);
1349 * gtk_file_chooser_get_uri:
1350 * @chooser: a #GtkFileChooser
1352 * Gets the URI for the currently selected file in
1353 * the file selector. If multiple files are selected,
1354 * one of the filenames will be returned at random.
1356 * If the file chooser is in folder mode, this function returns the selected
1359 * Return value: The currently selected URI, or %NULL
1360 * if no file is selected. Free with g_free()
1365 gtk_file_chooser_get_uri (GtkFileChooser *chooser)
1368 gchar *result = NULL;
1370 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1372 file = gtk_file_chooser_get_file (chooser);
1375 result = g_file_get_uri (file);
1376 g_object_unref (file);
1383 * gtk_file_chooser_set_uri:
1384 * @chooser: a #GtkFileChooser
1385 * @uri: the URI to set as current
1387 * Sets the file referred to by @uri as the current file for the file chooser,
1388 * by changing to the URI's parent folder and actually selecting the URI in the
1389 * list. If the @chooser is %GTK_FILE_CHOOSER_ACTION_SAVE mode, the URI's base
1390 * name will also appear in the dialog's file name entry.
1392 * If the URI isn't in the current folder of @chooser, then the current folder
1393 * of @chooser will be changed to the folder containing @uri. This is equivalent
1394 * to a sequence of gtk_file_chooser_unselect_all() followed by
1395 * gtk_file_chooser_select_uri().
1397 * Note that the URI must exist, or nothing will be done except for the
1399 * If you are implementing a <guimenuitem>File/Save As...</guimenuitem> dialog,
1400 * you should use this function if you already have a file name to which the
1401 * user may save; for example, when the user opens an existing file and then
1402 * does <guimenuitem>File/Save As...</guimenuitem> on it. If you don't have
1403 * a file name already — for example, if the user just created a new
1404 * file and is saving it for the first time, do not call this function.
1405 * Instead, use something similar to this:
1407 * if (document_is_new)
1409 * /* the user just created a new document */
1410 * gtk_file_chooser_set_current_folder_uri (chooser, default_folder_for_saving);
1411 * gtk_file_chooser_set_current_name (chooser, "Untitled document");
1415 * /* the user edited an existing document */
1416 * gtk_file_chooser_set_uri (chooser, existing_uri);
1420 * Return value: %TRUE if both the folder could be changed and the URI was
1421 * selected successfully, %FALSE otherwise.
1426 gtk_file_chooser_set_uri (GtkFileChooser *chooser,
1429 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1431 gtk_file_chooser_unselect_all (chooser);
1432 return gtk_file_chooser_select_uri (chooser, uri);
1436 * gtk_file_chooser_select_uri:
1437 * @chooser: a #GtkFileChooser
1438 * @uri: the URI to select
1440 * Selects the file to by @uri. If the URI doesn't refer to a
1441 * file in the current folder of @chooser, then the current folder of
1442 * @chooser will be changed to the folder containing @filename.
1444 * Return value: %TRUE if both the folder could be changed and the URI was
1445 * selected successfully, %FALSE otherwise.
1450 gtk_file_chooser_select_uri (GtkFileChooser *chooser,
1456 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1457 g_return_val_if_fail (uri != NULL, FALSE);
1459 file = g_file_new_for_uri (uri);
1460 result = gtk_file_chooser_select_file (chooser, file, NULL);
1461 g_object_unref (file);
1467 * gtk_file_chooser_unselect_uri:
1468 * @chooser: a #GtkFileChooser
1469 * @uri: the URI to unselect
1471 * Unselects the file referred to by @uri. If the file
1472 * is not in the current directory, does not exist, or
1473 * is otherwise not currently selected, does nothing.
1478 gtk_file_chooser_unselect_uri (GtkFileChooser *chooser,
1483 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1484 g_return_if_fail (uri != NULL);
1486 file = g_file_new_for_uri (uri);
1487 gtk_file_chooser_unselect_file (chooser, file);
1488 g_object_unref (file);
1492 * gtk_file_chooser_select_all:
1493 * @chooser: a #GtkFileChooser
1495 * Selects all the files in the current folder of a file chooser.
1500 gtk_file_chooser_select_all (GtkFileChooser *chooser)
1502 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1504 GTK_FILE_CHOOSER_GET_IFACE (chooser)->select_all (chooser);
1508 * gtk_file_chooser_unselect_all:
1509 * @chooser: a #GtkFileChooser
1511 * Unselects all the files in the current folder of a file chooser.
1516 gtk_file_chooser_unselect_all (GtkFileChooser *chooser)
1519 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1521 GTK_FILE_CHOOSER_GET_IFACE (chooser)->unselect_all (chooser);
1525 * gtk_file_chooser_get_uris:
1526 * @chooser: a #GtkFileChooser
1528 * Lists all the selected files and subfolders in the current folder of
1529 * @chooser. The returned names are full absolute URIs.
1531 * Return value: (element-type utf8) (transfer full): a #GSList containing the URIs of all selected
1532 * files and subfolders in the current folder. Free the returned list
1533 * with g_slist_free(), and the filenames with g_free().
1538 gtk_file_chooser_get_uris (GtkFileChooser *chooser)
1540 GSList *files, *result;
1542 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1544 files = gtk_file_chooser_get_files (chooser);
1546 result = files_to_strings (files, g_file_get_uri);
1547 g_slist_foreach (files, (GFunc) g_object_unref, NULL);
1548 g_slist_free (files);
1554 * gtk_file_chooser_set_current_folder_uri:
1555 * @chooser: a #GtkFileChooser
1556 * @uri: the URI for the new current folder
1558 * Sets the current folder for @chooser from an URI.
1559 * The user will be shown the full contents of the current folder,
1560 * plus user interface elements for navigating to other folders.
1562 * Return value: %TRUE if the folder could be changed successfully, %FALSE
1568 gtk_file_chooser_set_current_folder_uri (GtkFileChooser *chooser,
1574 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1575 g_return_val_if_fail (uri != NULL, FALSE);
1577 file = g_file_new_for_uri (uri);
1578 result = gtk_file_chooser_set_current_folder_file (chooser, file, NULL);
1579 g_object_unref (file);
1585 * gtk_file_chooser_get_current_folder_uri:
1586 * @chooser: a #GtkFileChooser
1588 * Gets the current folder of @chooser as an URI.
1589 * See gtk_file_chooser_set_current_folder_uri().
1591 * Note that this is the folder that the file chooser is currently displaying
1592 * (e.g. "file:///home/username/Documents"), which is <emphasis>not the same</emphasis>
1593 * as the currently-selected folder if the chooser is in
1594 * %GTK_FILE_CHOOSER_SELECT_FOLDER mode
1595 * (e.g. "file:///home/username/Documents/selected-folder/". To get the
1596 * currently-selected folder in that mode, use gtk_file_chooser_get_uri() as the
1597 * usual way to get the selection.
1599 * Return value: the URI for the current folder. Free with g_free(). This
1600 * function will also return %NULL if the file chooser was unable to load the
1601 * last folder that was requested from it; for example, as would be for calling
1602 * gtk_file_chooser_set_current_folder_uri() on a nonexistent folder.
1607 gtk_file_chooser_get_current_folder_uri (GtkFileChooser *chooser)
1612 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1614 file = gtk_file_chooser_get_current_folder_file (chooser);
1618 uri = g_file_get_uri (file);
1619 g_object_unref (file);
1625 * gtk_file_chooser_set_current_folder_file:
1626 * @chooser: a #GtkFileChooser
1627 * @file: the #GFile for the new folder
1628 * @error: (allow-none): location to store error, or %NULL.
1630 * Sets the current folder for @chooser from a #GFile.
1631 * Internal function, see gtk_file_chooser_set_current_folder_uri().
1633 * Return value: %TRUE if the folder could be changed successfully, %FALSE
1639 gtk_file_chooser_set_current_folder_file (GtkFileChooser *chooser,
1643 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1644 g_return_val_if_fail (G_IS_FILE (file), FALSE);
1645 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
1647 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->set_current_folder (chooser, file, error);
1651 * gtk_file_chooser_get_current_folder_file:
1652 * @chooser: a #GtkFileChooser
1654 * Gets the current folder of @chooser as #GFile.
1655 * See gtk_file_chooser_get_current_folder_uri().
1657 * Return value: the #GFile for the current folder.
1662 gtk_file_chooser_get_current_folder_file (GtkFileChooser *chooser)
1664 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1666 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_current_folder (chooser);
1670 * gtk_file_chooser_select_file:
1671 * @chooser: a #GtkFileChooser
1672 * @file: the file to select
1673 * @error: (allow-none): location to store error, or %NULL
1675 * Selects the file referred to by @file. An internal function. See
1676 * _gtk_file_chooser_select_uri().
1678 * Return value: %TRUE if both the folder could be changed and the path was
1679 * selected successfully, %FALSE otherwise.
1684 gtk_file_chooser_select_file (GtkFileChooser *chooser,
1688 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1689 g_return_val_if_fail (G_IS_FILE (file), FALSE);
1690 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
1692 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->select_file (chooser, file, error);
1696 * gtk_file_chooser_unselect_file:
1697 * @chooser: a #GtkFileChooser
1700 * Unselects the file referred to by @file. If the file is not in the current
1701 * directory, does not exist, or is otherwise not currently selected, does nothing.
1706 gtk_file_chooser_unselect_file (GtkFileChooser *chooser,
1709 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1710 g_return_if_fail (G_IS_FILE (file));
1712 GTK_FILE_CHOOSER_GET_IFACE (chooser)->unselect_file (chooser, file);
1716 * gtk_file_chooser_get_files:
1717 * @chooser: a #GtkFileChooser
1719 * Lists all the selected files and subfolders in the current folder of @chooser
1720 * as #GFile. An internal function, see gtk_file_chooser_get_uris().
1722 * Return value: (element-type utf8) (transfer full): a #GSList containing a #GFile for each selected
1723 * file and subfolder in the current folder. Free the returned list
1724 * with g_slist_free(), and the files with g_object_unref().
1729 gtk_file_chooser_get_files (GtkFileChooser *chooser)
1731 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1733 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_files (chooser);
1737 * gtk_file_chooser_set_file:
1738 * @chooser: a #GtkFileChooser
1739 * @file: the #GFile to set as current
1740 * @error: (allow-none): location to store the error, or %NULL to ignore errors.
1742 * Sets @file as the current filename for the file chooser, by changing
1743 * to the file's parent folder and actually selecting the file in list. If
1744 * the @chooser is in %GTK_FILE_CHOOSER_ACTION_SAVE mode, the file's base name
1745 * will also appear in the dialog's file name entry.
1747 * If the file name isn't in the current folder of @chooser, then the current
1748 * folder of @chooser will be changed to the folder containing @filename. This
1749 * is equivalent to a sequence of gtk_file_chooser_unselect_all() followed by
1750 * gtk_file_chooser_select_filename().
1752 * Note that the file must exist, or nothing will be done except
1753 * for the directory change.
1755 * If you are implementing a <guimenuitem>File/Save As...</guimenuitem> dialog,
1756 * you should use this function if you already have a file name to which the
1757 * user may save; for example, when the user opens an existing file and then
1758 * does <guimenuitem>File/Save As...</guimenuitem> on it. If you don't have
1759 * a file name already — for example, if the user just created a new
1760 * file and is saving it for the first time, do not call this function.
1761 * Instead, use something similar to this:
1763 * if (document_is_new)
1765 * /* the user just created a new document */
1766 * gtk_file_chooser_set_current_folder_file (chooser, default_file_for_saving);
1767 * gtk_file_chooser_set_current_name (chooser, "Untitled document");
1771 * /* the user edited an existing document */
1772 * gtk_file_chooser_set_file (chooser, existing_file);
1776 * Return value: %TRUE if both the folder could be changed and the file was
1777 * selected successfully, %FALSE otherwise.
1782 gtk_file_chooser_set_file (GtkFileChooser *chooser,
1786 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1787 g_return_val_if_fail (G_IS_FILE (file), FALSE);
1788 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
1790 gtk_file_chooser_unselect_all (chooser);
1791 return gtk_file_chooser_select_file (chooser, file, error);
1795 * gtk_file_chooser_get_file:
1796 * @chooser: a #GtkFileChooser
1798 * Gets the #GFile for the currently selected file in
1799 * the file selector. If multiple files are selected,
1800 * one of the files will be returned at random.
1802 * If the file chooser is in folder mode, this function returns the selected
1805 * Returns: a selected #GFile. You own the returned file; use
1806 * g_object_unref() to release it.
1811 gtk_file_chooser_get_file (GtkFileChooser *chooser)
1814 GFile *result = NULL;
1816 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1818 list = gtk_file_chooser_get_files (chooser);
1821 result = list->data;
1822 list = g_slist_delete_link (list, list);
1824 g_slist_foreach (list, (GFunc) g_object_unref, NULL);
1825 g_slist_free (list);
1832 * _gtk_file_chooser_get_file_system:
1833 * @chooser: a #GtkFileChooser
1835 * Gets the #GtkFileSystem of @chooser; this is an internal
1836 * implementation detail, used for conversion between paths
1837 * and filenames and URIs.
1839 * Return value: the file system for @chooser.
1844 _gtk_file_chooser_get_file_system (GtkFileChooser *chooser)
1846 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1848 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_file_system (chooser);
1854 * gtk_file_chooser_set_preview_widget:
1855 * @chooser: a #GtkFileChooser
1856 * @preview_widget: widget for displaying preview.
1858 * Sets an application-supplied widget to use to display a custom preview
1859 * of the currently selected file. To implement a preview, after setting the
1860 * preview widget, you connect to the #GtkFileChooser::update-preview
1861 * signal, and call gtk_file_chooser_get_preview_filename() or
1862 * gtk_file_chooser_get_preview_uri() on each change. If you can
1863 * display a preview of the new file, update your widget and
1864 * set the preview active using gtk_file_chooser_set_preview_widget_active().
1865 * Otherwise, set the preview inactive.
1867 * When there is no application-supplied preview widget, or the
1868 * application-supplied preview widget is not active, the file chooser
1869 * may display an internally generated preview of the current file or
1870 * it may display no preview at all.
1875 gtk_file_chooser_set_preview_widget (GtkFileChooser *chooser,
1876 GtkWidget *preview_widget)
1878 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1880 g_object_set (chooser, "preview-widget", preview_widget, NULL);
1884 * gtk_file_chooser_get_preview_widget:
1885 * @chooser: a #GtkFileChooser
1887 * Gets the current preview widget; see
1888 * gtk_file_chooser_set_preview_widget().
1890 * Return value: the current preview widget, or %NULL
1895 gtk_file_chooser_get_preview_widget (GtkFileChooser *chooser)
1897 GtkWidget *preview_widget;
1899 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1901 g_object_get (chooser, "preview-widget", &preview_widget, NULL);
1903 /* Horrid hack; g_object_get() refs returned objects but
1904 * that contradicts the memory management conventions
1908 g_object_unref (preview_widget);
1910 return preview_widget;
1914 * gtk_file_chooser_set_preview_widget_active:
1915 * @chooser: a #GtkFileChooser
1916 * @active: whether to display the user-specified preview widget
1918 * Sets whether the preview widget set by
1919 * gtk_file_chooser_set_preview_widget() should be shown for the
1920 * current filename. When @active is set to false, the file chooser
1921 * may display an internally generated preview of the current file
1922 * or it may display no preview at all. See
1923 * gtk_file_chooser_set_preview_widget() for more details.
1928 gtk_file_chooser_set_preview_widget_active (GtkFileChooser *chooser,
1931 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1933 g_object_set (chooser, "preview-widget-active", active, NULL);
1937 * gtk_file_chooser_get_preview_widget_active:
1938 * @chooser: a #GtkFileChooser
1940 * Gets whether the preview widget set by gtk_file_chooser_set_preview_widget()
1941 * should be shown for the current filename. See
1942 * gtk_file_chooser_set_preview_widget_active().
1944 * Return value: %TRUE if the preview widget is active for the current filename.
1949 gtk_file_chooser_get_preview_widget_active (GtkFileChooser *chooser)
1953 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1955 g_object_get (chooser, "preview-widget-active", &active, NULL);
1961 * gtk_file_chooser_set_use_preview_label:
1962 * @chooser: a #GtkFileChooser
1963 * @use_label: whether to display a stock label with the name of the previewed file
1965 * Sets whether the file chooser should display a stock label with the name of
1966 * the file that is being previewed; the default is %TRUE. Applications that
1967 * want to draw the whole preview area themselves should set this to %FALSE and
1968 * display the name themselves in their preview widget.
1970 * See also: gtk_file_chooser_set_preview_widget()
1975 gtk_file_chooser_set_use_preview_label (GtkFileChooser *chooser,
1978 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1980 g_object_set (chooser, "use-preview-label", use_label, NULL);
1984 * gtk_file_chooser_get_use_preview_label:
1985 * @chooser: a #GtkFileChooser
1987 * Gets whether a stock label should be drawn with the name of the previewed
1988 * file. See gtk_file_chooser_set_use_preview_label().
1990 * Return value: %TRUE if the file chooser is set to display a label with the
1991 * name of the previewed file, %FALSE otherwise.
1994 gtk_file_chooser_get_use_preview_label (GtkFileChooser *chooser)
1998 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2000 g_object_get (chooser, "use-preview-label", &use_label, NULL);
2006 * gtk_file_chooser_get_preview_file:
2007 * @chooser: a #GtkFileChooser
2009 * Gets the #GFile that should be previewed in a custom preview
2010 * Internal function, see gtk_file_chooser_get_preview_uri().
2012 * Return value: the #GFile for the file to preview, or %NULL if no file
2013 * is selected. Free with g_object_unref().
2018 gtk_file_chooser_get_preview_file (GtkFileChooser *chooser)
2020 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2022 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_preview_file (chooser);
2026 * _gtk_file_chooser_add_shortcut_folder:
2027 * @chooser: a #GtkFileChooser
2028 * @file: file for the folder to add
2029 * @error: (allow-none): location to store error, or %NULL
2031 * Adds a folder to be displayed with the shortcut folders in a file chooser.
2032 * Internal function, see gtk_file_chooser_add_shortcut_folder().
2034 * Return value: %TRUE if the folder could be added successfully, %FALSE
2040 _gtk_file_chooser_add_shortcut_folder (GtkFileChooser *chooser,
2044 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2045 g_return_val_if_fail (G_IS_FILE (file), FALSE);
2047 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_shortcut_folder (chooser, file, error);
2051 * _gtk_file_chooser_remove_shortcut_folder:
2052 * @chooser: a #GtkFileChooser
2053 * @file: file for the folder to remove
2054 * @error: (allow-none): location to store error, or %NULL
2056 * Removes a folder from the shortcut folders in a file chooser. Internal
2057 * function, see gtk_file_chooser_remove_shortcut_folder().
2059 * Return value: %TRUE if the folder could be removed successfully, %FALSE
2065 _gtk_file_chooser_remove_shortcut_folder (GtkFileChooser *chooser,
2069 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2070 g_return_val_if_fail (G_IS_FILE (file), FALSE);
2072 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_shortcut_folder (chooser, file, error);
2076 * gtk_file_chooser_get_preview_filename:
2077 * @chooser: a #GtkFileChooser
2079 * Gets the filename that should be previewed in a custom preview
2080 * widget. See gtk_file_chooser_set_preview_widget().
2082 * Return value: the filename to preview, or %NULL if no file
2083 * is selected, or if the selected file cannot be represented
2084 * as a local filename. Free with g_free()
2089 gtk_file_chooser_get_preview_filename (GtkFileChooser *chooser)
2092 gchar *result = NULL;
2094 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2096 file = gtk_file_chooser_get_preview_file (chooser);
2099 result = g_file_get_path (file);
2100 g_object_unref (file);
2107 * gtk_file_chooser_get_preview_uri:
2108 * @chooser: a #GtkFileChooser
2110 * Gets the URI that should be previewed in a custom preview
2111 * widget. See gtk_file_chooser_set_preview_widget().
2113 * Return value: the URI for the file to preview, or %NULL if no file is
2114 * selected. Free with g_free().
2119 gtk_file_chooser_get_preview_uri (GtkFileChooser *chooser)
2122 gchar *result = NULL;
2124 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2126 file = gtk_file_chooser_get_preview_file (chooser);
2129 result = g_file_get_uri (file);
2130 g_object_unref (file);
2137 * gtk_file_chooser_set_extra_widget:
2138 * @chooser: a #GtkFileChooser
2139 * @extra_widget: widget for extra options
2141 * Sets an application-supplied widget to provide extra options to the user.
2146 gtk_file_chooser_set_extra_widget (GtkFileChooser *chooser,
2147 GtkWidget *extra_widget)
2149 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
2151 g_object_set (chooser, "extra-widget", extra_widget, NULL);
2155 * gtk_file_chooser_get_extra_widget:
2156 * @chooser: a #GtkFileChooser
2158 * Gets the current preview widget; see
2159 * gtk_file_chooser_set_extra_widget().
2161 * Return value: the current extra widget, or %NULL
2166 gtk_file_chooser_get_extra_widget (GtkFileChooser *chooser)
2168 GtkWidget *extra_widget;
2170 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2172 g_object_get (chooser, "extra-widget", &extra_widget, NULL);
2174 /* Horrid hack; g_object_get() refs returned objects but
2175 * that contradicts the memory management conventions
2179 g_object_unref (extra_widget);
2181 return extra_widget;
2185 * gtk_file_chooser_add_filter:
2186 * @chooser: a #GtkFileChooser
2187 * @filter: a #GtkFileFilter
2189 * Adds @filter to the list of filters that the user can select between.
2190 * When a filter is selected, only files that are passed by that
2191 * filter are displayed.
2193 * Note that the @chooser takes ownership of the filter, so you have to
2194 * ref and sink it if you want to keep a reference.
2199 gtk_file_chooser_add_filter (GtkFileChooser *chooser,
2200 GtkFileFilter *filter)
2202 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
2204 GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_filter (chooser, filter);
2208 * gtk_file_chooser_remove_filter:
2209 * @chooser: a #GtkFileChooser
2210 * @filter: a #GtkFileFilter
2212 * Removes @filter from the list of filters that the user can select between.
2217 gtk_file_chooser_remove_filter (GtkFileChooser *chooser,
2218 GtkFileFilter *filter)
2220 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
2222 GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_filter (chooser, filter);
2226 * gtk_file_chooser_list_filters:
2227 * @chooser: a #GtkFileChooser
2229 * Lists the current set of user-selectable filters; see
2230 * gtk_file_chooser_add_filter(), gtk_file_chooser_remove_filter().
2232 * Return value: (element-type utf8) (transfer container): a #GSList containing the current set of
2233 * user selectable filters. The contents of the list are
2234 * owned by GTK+, but you must free the list itself with
2235 * g_slist_free() when you are done with it.
2240 gtk_file_chooser_list_filters (GtkFileChooser *chooser)
2242 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2244 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->list_filters (chooser);
2248 * gtk_file_chooser_set_filter:
2249 * @chooser: a #GtkFileChooser
2250 * @filter: a #GtkFileFilter
2252 * Sets the current filter; only the files that pass the
2253 * filter will be displayed. If the user-selectable list of filters
2254 * is non-empty, then the filter should be one of the filters
2255 * in that list. Setting the current filter when the list of
2256 * filters is empty is useful if you want to restrict the displayed
2257 * set of files without letting the user change it.
2262 gtk_file_chooser_set_filter (GtkFileChooser *chooser,
2263 GtkFileFilter *filter)
2265 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
2266 g_return_if_fail (GTK_IS_FILE_FILTER (filter));
2268 g_object_set (chooser, "filter", filter, NULL);
2272 * gtk_file_chooser_get_filter:
2273 * @chooser: a #GtkFileChooser
2275 * Gets the current filter; see gtk_file_chooser_set_filter().
2277 * Return value: the current filter, or %NULL
2282 gtk_file_chooser_get_filter (GtkFileChooser *chooser)
2284 GtkFileFilter *filter;
2286 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2288 g_object_get (chooser, "filter", &filter, NULL);
2289 /* Horrid hack; g_object_get() refs returned objects but
2290 * that contradicts the memory management conventions
2294 g_object_unref (filter);
2300 * gtk_file_chooser_add_shortcut_folder:
2301 * @chooser: a #GtkFileChooser
2302 * @folder: filename of the folder to add
2303 * @error: (allow-none): location to store error, or %NULL
2305 * Adds a folder to be displayed with the shortcut folders in a file chooser.
2306 * Note that shortcut folders do not get saved, as they are provided by the
2307 * application. For example, you can use this to add a
2308 * "/usr/share/mydrawprogram/Clipart" folder to the volume list.
2310 * Return value: %TRUE if the folder could be added successfully, %FALSE
2311 * otherwise. In the latter case, the @error will be set as appropriate.
2316 gtk_file_chooser_add_shortcut_folder (GtkFileChooser *chooser,
2323 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2324 g_return_val_if_fail (folder != NULL, FALSE);
2326 file = g_file_new_for_path (folder);
2327 result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_shortcut_folder (chooser, file, error);
2328 g_object_unref (file);
2334 * gtk_file_chooser_remove_shortcut_folder:
2335 * @chooser: a #GtkFileChooser
2336 * @folder: filename of the folder to remove
2337 * @error: (allow-none): location to store error, or %NULL
2339 * Removes a folder from a file chooser's list of shortcut folders.
2341 * Return value: %TRUE if the operation succeeds, %FALSE otherwise.
2342 * In the latter case, the @error will be set as appropriate.
2344 * See also: gtk_file_chooser_add_shortcut_folder()
2349 gtk_file_chooser_remove_shortcut_folder (GtkFileChooser *chooser,
2356 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2357 g_return_val_if_fail (folder != NULL, FALSE);
2359 file = g_file_new_for_path (folder);
2360 result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_shortcut_folder (chooser, file, error);
2361 g_object_unref (file);
2367 * gtk_file_chooser_list_shortcut_folders:
2368 * @chooser: a #GtkFileChooser
2370 * Queries the list of shortcut folders in the file chooser, as set by
2371 * gtk_file_chooser_add_shortcut_folder().
2373 * Return value: (element-type utf8) (transfer full): A list of folder filenames, or %NULL if there are no shortcut
2374 * folders. Free the returned list with g_slist_free(), and the filenames with
2380 gtk_file_chooser_list_shortcut_folders (GtkFileChooser *chooser)
2385 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2387 folders = _gtk_file_chooser_list_shortcut_folder_files (chooser);
2389 result = files_to_strings (folders, g_file_get_path);
2390 g_slist_foreach (folders, (GFunc) g_object_unref, NULL);
2391 g_slist_free (folders);
2397 * gtk_file_chooser_add_shortcut_folder_uri:
2398 * @chooser: a #GtkFileChooser
2399 * @uri: URI of the folder to add
2400 * @error: (allow-none): location to store error, or %NULL
2402 * Adds a folder URI to be displayed with the shortcut folders in a file
2403 * chooser. Note that shortcut folders do not get saved, as they are provided
2404 * by the application. For example, you can use this to add a
2405 * "file:///usr/share/mydrawprogram/Clipart" folder to the volume list.
2407 * Return value: %TRUE if the folder could be added successfully, %FALSE
2408 * otherwise. In the latter case, the @error will be set as appropriate.
2413 gtk_file_chooser_add_shortcut_folder_uri (GtkFileChooser *chooser,
2420 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2421 g_return_val_if_fail (uri != NULL, FALSE);
2423 file = g_file_new_for_uri (uri);
2424 result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_shortcut_folder (chooser, file, error);
2425 g_object_unref (file);
2431 * gtk_file_chooser_remove_shortcut_folder_uri:
2432 * @chooser: a #GtkFileChooser
2433 * @uri: URI of the folder to remove
2434 * @error: (allow-none): location to store error, or %NULL
2436 * Removes a folder URI from a file chooser's list of shortcut folders.
2438 * Return value: %TRUE if the operation succeeds, %FALSE otherwise.
2439 * In the latter case, the @error will be set as appropriate.
2441 * See also: gtk_file_chooser_add_shortcut_folder_uri()
2446 gtk_file_chooser_remove_shortcut_folder_uri (GtkFileChooser *chooser,
2453 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2454 g_return_val_if_fail (uri != NULL, FALSE);
2456 file = g_file_new_for_uri (uri);
2457 result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_shortcut_folder (chooser, file, error);
2458 g_object_unref (file);
2464 * gtk_file_chooser_list_shortcut_folder_uris:
2465 * @chooser: a #GtkFileChooser
2467 * Queries the list of shortcut folders in the file chooser, as set by
2468 * gtk_file_chooser_add_shortcut_folder_uri().
2470 * Return value: (element-type utf8) (transfer full): A list of folder URIs, or %NULL if there are no shortcut
2471 * folders. Free the returned list with g_slist_free(), and the URIs with
2477 gtk_file_chooser_list_shortcut_folder_uris (GtkFileChooser *chooser)
2482 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2484 folders = _gtk_file_chooser_list_shortcut_folder_files (chooser);
2486 result = files_to_strings (folders, g_file_get_uri);
2487 g_slist_foreach (folders, (GFunc) g_object_unref, NULL);
2488 g_slist_free (folders);
2494 _gtk_file_chooser_list_shortcut_folder_files (GtkFileChooser *chooser)
2496 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2498 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->list_shortcut_folders (chooser);
2502 * gtk_file_chooser_set_show_hidden:
2503 * @chooser: a #GtkFileChooser
2504 * @show_hidden: %TRUE if hidden files and folders should be displayed.
2506 * Sets whether hidden files and folders are displayed in the file selector.
2511 gtk_file_chooser_set_show_hidden (GtkFileChooser *chooser,
2512 gboolean show_hidden)
2514 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
2516 g_object_set (chooser, "show-hidden", show_hidden, NULL);
2520 * gtk_file_chooser_get_show_hidden:
2521 * @chooser: a #GtkFileChooser
2523 * Gets whether hidden files and folders are displayed in the file selector.
2524 * See gtk_file_chooser_set_show_hidden().
2526 * Return value: %TRUE if hidden files and folders are displayed.
2531 gtk_file_chooser_get_show_hidden (GtkFileChooser *chooser)
2533 gboolean show_hidden;
2535 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2537 g_object_get (chooser, "show-hidden", &show_hidden, NULL);
2543 * gtk_file_chooser_set_do_overwrite_confirmation:
2544 * @chooser: a #GtkFileChooser
2545 * @do_overwrite_confirmation: whether to confirm overwriting in save mode
2547 * Sets whether a file chooser in %GTK_FILE_CHOOSER_ACTION_SAVE mode will present
2548 * a confirmation dialog if the user types a file name that already exists. This
2549 * is %FALSE by default.
2551 * Regardless of this setting, the @chooser will emit the
2552 * #GtkFileChooser::confirm-overwrite signal when appropriate.
2554 * If all you need is the stock confirmation dialog, set this property to %TRUE.
2555 * You can override the way confirmation is done by actually handling the
2556 * #GtkFileChooser::confirm-overwrite signal; please refer to its documentation
2562 gtk_file_chooser_set_do_overwrite_confirmation (GtkFileChooser *chooser,
2563 gboolean do_overwrite_confirmation)
2565 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
2567 g_object_set (chooser, "do-overwrite-confirmation", do_overwrite_confirmation, NULL);
2571 * gtk_file_chooser_get_do_overwrite_confirmation:
2572 * @chooser: a #GtkFileChooser
2574 * Queries whether a file chooser is set to confirm for overwriting when the user
2575 * types a file name that already exists.
2577 * Return value: %TRUE if the file chooser will present a confirmation dialog;
2583 gtk_file_chooser_get_do_overwrite_confirmation (GtkFileChooser *chooser)
2585 gboolean do_overwrite_confirmation;
2587 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2589 g_object_get (chooser, "do-overwrite-confirmation", &do_overwrite_confirmation, NULL);
2591 return do_overwrite_confirmation;
2594 #if defined (G_OS_WIN32) && !defined (_WIN64)
2596 /* DLL ABI stability backward compatibility versions */
2598 #undef gtk_file_chooser_get_filename
2601 gtk_file_chooser_get_filename (GtkFileChooser *chooser)
2603 gchar *utf8_filename = gtk_file_chooser_get_filename_utf8 (chooser);
2604 gchar *retval = g_locale_from_utf8 (utf8_filename, -1, NULL, NULL, NULL);
2606 g_free (utf8_filename);
2611 #undef gtk_file_chooser_set_filename
2614 gtk_file_chooser_set_filename (GtkFileChooser *chooser,
2615 const gchar *filename)
2617 gchar *utf8_filename = g_locale_to_utf8 (filename, -1, NULL, NULL, NULL);
2618 gboolean retval = gtk_file_chooser_set_filename_utf8 (chooser, utf8_filename);
2620 g_free (utf8_filename);
2625 #undef gtk_file_chooser_select_filename
2628 gtk_file_chooser_select_filename (GtkFileChooser *chooser,
2629 const gchar *filename)
2631 gchar *utf8_filename = g_locale_to_utf8 (filename, -1, NULL, NULL, NULL);
2632 gboolean retval = gtk_file_chooser_select_filename_utf8 (chooser, utf8_filename);
2634 g_free (utf8_filename);
2639 #undef gtk_file_chooser_unselect_filename
2642 gtk_file_chooser_unselect_filename (GtkFileChooser *chooser,
2643 const char *filename)
2645 gchar *utf8_filename = g_locale_to_utf8 (filename, -1, NULL, NULL, NULL);
2647 gtk_file_chooser_unselect_filename_utf8 (chooser, utf8_filename);
2648 g_free (utf8_filename);
2651 #undef gtk_file_chooser_get_filenames
2654 gtk_file_chooser_get_filenames (GtkFileChooser *chooser)
2656 GSList *list = gtk_file_chooser_get_filenames_utf8 (chooser);
2657 GSList *rover = list;
2661 gchar *tem = (gchar *) rover->data;
2662 rover->data = g_locale_from_utf8 ((gchar *) rover->data, -1, NULL, NULL, NULL);
2664 rover = rover->next;
2670 #undef gtk_file_chooser_set_current_folder
2673 gtk_file_chooser_set_current_folder (GtkFileChooser *chooser,
2674 const gchar *filename)
2676 gchar *utf8_filename = g_locale_to_utf8 (filename, -1, NULL, NULL, NULL);
2677 gboolean retval = gtk_file_chooser_set_current_folder_utf8 (chooser, utf8_filename);
2679 g_free (utf8_filename);
2684 #undef gtk_file_chooser_get_current_folder
2687 gtk_file_chooser_get_current_folder (GtkFileChooser *chooser)
2689 gchar *utf8_folder = gtk_file_chooser_get_current_folder_utf8 (chooser);
2690 gchar *retval = g_locale_from_utf8 (utf8_folder, -1, NULL, NULL, NULL);
2692 g_free (utf8_folder);
2697 #undef gtk_file_chooser_get_preview_filename
2700 gtk_file_chooser_get_preview_filename (GtkFileChooser *chooser)
2702 char *utf8_filename = gtk_file_chooser_get_preview_filename_utf8 (chooser);
2703 char *retval = g_locale_from_utf8 (utf8_filename, -1, NULL, NULL, NULL);
2705 g_free (utf8_filename);
2710 #undef gtk_file_chooser_add_shortcut_folder
2713 gtk_file_chooser_add_shortcut_folder (GtkFileChooser *chooser,
2717 char *utf8_folder = g_locale_to_utf8 (folder, -1, NULL, NULL, NULL);
2719 gtk_file_chooser_add_shortcut_folder_utf8 (chooser, utf8_folder, error);
2721 g_free (utf8_folder);
2726 #undef gtk_file_chooser_remove_shortcut_folder
2729 gtk_file_chooser_remove_shortcut_folder (GtkFileChooser *chooser,
2733 char *utf8_folder = g_locale_to_utf8 (folder, -1, NULL, NULL, NULL);
2735 gtk_file_chooser_remove_shortcut_folder_utf8 (chooser, utf8_folder, error);
2737 g_free (utf8_folder);
2742 #undef gtk_file_chooser_list_shortcut_folders
2745 gtk_file_chooser_list_shortcut_folders (GtkFileChooser *chooser)
2747 GSList *list = gtk_file_chooser_list_shortcut_folders_utf8 (chooser);
2748 GSList *rover = list;
2752 gchar *tem = (gchar *) rover->data;
2753 rover->data = g_locale_from_utf8 ((gchar *) rover->data, -1, NULL, NULL, NULL);
2755 rover = rover->next;
2763 #define __GTK_FILE_CHOOSER_C__
2764 #include "gtkaliasdef.c"