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.
507 * <term><parameter>bookmark_index</parameter> :</term>
510 * index of the bookmark to switch to; the indices start at 0.
515 * <term><parameter>user_data</parameter> :</term>
518 * user data set when the signal handler was connected.
528 static void gtk_file_chooser_class_init (gpointer g_iface);
531 gtk_file_chooser_get_type (void)
533 static GType file_chooser_type = 0;
535 if (!file_chooser_type)
537 file_chooser_type = g_type_register_static_simple (G_TYPE_INTERFACE,
538 I_("GtkFileChooser"),
539 sizeof (GtkFileChooserIface),
540 (GClassInitFunc) gtk_file_chooser_class_init,
543 g_type_interface_add_prerequisite (file_chooser_type, GTK_TYPE_WIDGET);
546 return file_chooser_type;
550 confirm_overwrite_accumulator (GSignalInvocationHint *ihint,
552 const GValue *handler_return,
555 gboolean continue_emission;
556 GtkFileChooserConfirmation conf;
558 conf = g_value_get_enum (handler_return);
559 g_value_set_enum (return_accu, conf);
560 continue_emission = (conf == GTK_FILE_CHOOSER_CONFIRMATION_CONFIRM);
562 return continue_emission;
566 gtk_file_chooser_class_init (gpointer g_iface)
568 GType iface_type = G_TYPE_FROM_INTERFACE (g_iface);
571 * GtkFileChooser::current-folder-changed
572 * @chooser: the object which received the signal.
574 * This signal is emitted when the current folder in a #GtkFileChooser
575 * changes. This can happen due to the user performing some action that
576 * changes folders, such as selecting a bookmark or visiting a folder on the
577 * file list. It can also happen as a result of calling a function to
578 * explicitly change the current folder in a file chooser.
580 * Normally you do not need to connect to this signal, unless you need to keep
581 * track of which folder a file chooser is showing.
583 * See also: gtk_file_chooser_set_current_folder(),
584 * gtk_file_chooser_get_current_folder(),
585 * gtk_file_chooser_set_current_folder_uri(),
586 * gtk_file_chooser_get_current_folder_uri().
588 g_signal_new (I_("current-folder-changed"),
591 G_STRUCT_OFFSET (GtkFileChooserIface, current_folder_changed),
593 g_cclosure_marshal_VOID__VOID,
597 * GtkFileChooser::selection-changed
598 * @chooser: the object which received the signal.
600 * This signal is emitted when there is a change in the set of selected files
601 * in a #GtkFileChooser. This can happen when the user modifies the selection
602 * with the mouse or the keyboard, or when explicitly calling functions to
603 * change the selection.
605 * Normally you do not need to connect to this signal, as it is easier to wait
606 * for the file chooser to finish running, and then to get the list of
607 * selected files using the functions mentioned below.
609 * See also: gtk_file_chooser_select_filename(),
610 * gtk_file_chooser_unselect_filename(), gtk_file_chooser_get_filename(),
611 * gtk_file_chooser_get_filenames(), gtk_file_chooser_select_uri(),
612 * gtk_file_chooser_unselect_uri(), gtk_file_chooser_get_uri(),
613 * gtk_file_chooser_get_uris().
615 g_signal_new (I_("selection-changed"),
618 G_STRUCT_OFFSET (GtkFileChooserIface, selection_changed),
620 g_cclosure_marshal_VOID__VOID,
624 * GtkFileChooser::update-preview
625 * @chooser: the object which received the signal.
627 * This signal is emitted when the preview in a file chooser should be
628 * regenerated. For example, this can happen when the currently selected file
629 * changes. You should use this signal if you want your file chooser to have
632 * Once you have installed a preview widget with
633 * gtk_file_chooser_set_preview_widget(), you should update it when this
634 * signal is emitted. You can use the functions
635 * gtk_file_chooser_get_preview_filename() or
636 * gtk_file_chooser_get_preview_uri() to get the name of the file to preview.
637 * Your widget may not be able to preview all kinds of files; your callback
638 * must call gtk_file_chooser_set_preview_widget_active() to inform the file
639 * chooser about whether the preview was generated successfully or not.
641 * Please see the example code in <xref linkend="gtkfilechooser-preview"/>.
643 * See also: gtk_file_chooser_set_preview_widget(),
644 * gtk_file_chooser_set_preview_widget_active(),
645 * gtk_file_chooser_set_use_preview_label(),
646 * gtk_file_chooser_get_preview_filename(),
647 * gtk_file_chooser_get_preview_uri().
649 g_signal_new (I_("update-preview"),
652 G_STRUCT_OFFSET (GtkFileChooserIface, update_preview),
654 g_cclosure_marshal_VOID__VOID,
658 * GtkFileChooser::file-activated
659 * @chooser: the object which received the signal.
661 * This signal is emitted when the user "activates" a file in the file
662 * chooser. This can happen by double-clicking on a file in the file list, or
663 * by pressing <keycap>Enter</keycap>.
665 * Normally you do not need to connect to this signal. It is used internally
666 * by #GtkFileChooserDialog to know when to activate the default button in the
669 * See also: gtk_file_chooser_get_filename(),
670 * gtk_file_chooser_get_filenames(), gtk_file_chooser_get_uri(),
671 * gtk_file_chooser_get_uris().
673 g_signal_new (I_("file-activated"),
676 G_STRUCT_OFFSET (GtkFileChooserIface, file_activated),
678 g_cclosure_marshal_VOID__VOID,
682 * GtkFileChooser::confirm-overwrite:
683 * @chooser: the object which received the signal.
685 * This signal gets emitted whenever it is appropriate to present a
686 * confirmation dialog when the user has selected a file name that
687 * already exists. The signal only gets emitted when the file
688 * chooser is in %GTK_FILE_CHOOSER_ACTION_SAVE mode.
690 * Most applications just need to turn on the
691 * #GtkFileChooser:do-overwrite-confirmation property (or call the
692 * gtk_file_chooser_set_do_overwrite_confirmation() function), and
693 * they will automatically get a stock confirmation dialog.
694 * Applications which need to customize this behavior should do
695 * that, and also connect to the #GtkFileChooser::confirm-overwrite
698 * A signal handler for this signal must return a
699 * #GtkFileChooserConfirmation value, which indicates the action to
700 * take. If the handler determines that the user wants to select a
701 * different filename, it should return
702 * %GTK_FILE_CHOOSER_CONFIRMATION_SELECT_AGAIN. If it determines
703 * that the user is satisfied with his choice of file name, it
704 * should return %GTK_FILE_CHOOSER_CONFIRMATION_ACCEPT_FILENAME.
705 * On the other hand, if it determines that the stock confirmation
706 * dialog should be used, it should return
707 * %GTK_FILE_CHOOSER_CONFIRMATION_CONFIRM. The following example
709 * <example id="gtkfilechooser-confirmation">
710 * <title>Custom confirmation</title>
712 * static GtkFileChooserConfirmation
713 * confirm_overwrite_callback (GtkFileChooser *chooser, gpointer data)
717 * uri = gtk_file_chooser_get_uri (chooser);
719 * if (is_uri_read_only (uri))
721 * if (user_wants_to_replace_read_only_file (uri))
722 * return GTK_FILE_CHOOSER_CONFIRMATION_ACCEPT_FILENAME;
724 * return GTK_FILE_CHOOSER_CONFIRMATION_SELECT_AGAIN;
726 * return GTK_FILE_CHOOSER_CONFIRMATION_CONFIRM; // fall back to the default dialog
731 * chooser = gtk_file_chooser_dialog_new (...);
733 * gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), TRUE);
734 * g_signal_connect (chooser, "confirm-overwrite",
735 * G_CALLBACK (confirm_overwrite_callback), NULL);
737 * if (gtk_dialog_run (chooser) == GTK_RESPONSE_ACCEPT)
738 * save_to_file (gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (chooser));
740 * gtk_widget_destroy (chooser);
744 * Returns: a #GtkFileChooserConfirmation value that indicates which
745 * action to take after emitting the signal.
749 g_signal_new (I_("confirm-overwrite"),
752 G_STRUCT_OFFSET (GtkFileChooserIface, confirm_overwrite),
753 confirm_overwrite_accumulator, NULL,
754 _gtk_marshal_ENUM__VOID,
755 GTK_TYPE_FILE_CHOOSER_CONFIRMATION, 0);
757 g_object_interface_install_property (g_iface,
758 g_param_spec_enum ("action",
760 P_("The type of operation that the file selector is performing"),
761 GTK_TYPE_FILE_CHOOSER_ACTION,
762 GTK_FILE_CHOOSER_ACTION_OPEN,
763 GTK_PARAM_READWRITE));
764 g_object_interface_install_property (g_iface,
765 g_param_spec_string ("file-system-backend",
766 P_("File System Backend"),
767 P_("Name of file system backend to use"),
769 GTK_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
770 g_object_interface_install_property (g_iface,
771 g_param_spec_object ("filter",
773 P_("The current filter for selecting which files are displayed"),
774 GTK_TYPE_FILE_FILTER,
775 GTK_PARAM_READWRITE));
776 g_object_interface_install_property (g_iface,
777 g_param_spec_boolean ("local-only",
779 P_("Whether the selected file(s) should be limited to local file: URLs"),
781 GTK_PARAM_READWRITE));
782 g_object_interface_install_property (g_iface,
783 g_param_spec_object ("preview-widget",
784 P_("Preview widget"),
785 P_("Application supplied widget for custom previews."),
787 GTK_PARAM_READWRITE));
788 g_object_interface_install_property (g_iface,
789 g_param_spec_boolean ("preview-widget-active",
790 P_("Preview Widget Active"),
791 P_("Whether the application supplied widget for custom previews should be shown."),
793 GTK_PARAM_READWRITE));
794 g_object_interface_install_property (g_iface,
795 g_param_spec_boolean ("use-preview-label",
796 P_("Use Preview Label"),
797 P_("Whether to display a stock label with the name of the previewed file."),
799 GTK_PARAM_READWRITE));
800 g_object_interface_install_property (g_iface,
801 g_param_spec_object ("extra-widget",
803 P_("Application supplied widget for extra options."),
805 GTK_PARAM_READWRITE));
806 g_object_interface_install_property (g_iface,
807 g_param_spec_boolean ("select-multiple",
808 P_("Select Multiple"),
809 P_("Whether to allow multiple files to be selected"),
811 GTK_PARAM_READWRITE));
813 g_object_interface_install_property (g_iface,
814 g_param_spec_boolean ("show-hidden",
816 P_("Whether the hidden files and folders should be displayed"),
818 GTK_PARAM_READWRITE));
821 * GtkFileChooser:do-overwrite-confirmation:
823 * Whether a file chooser in %GTK_FILE_CHOOSER_ACTION_SAVE mode
824 * will present an overwrite confirmation dialog if the user
825 * selects a file name that already exists.
829 g_object_interface_install_property (g_iface,
830 g_param_spec_boolean ("do-overwrite-confirmation",
831 P_("Do overwrite confirmation"),
832 P_("Whether a file chooser in save mode "
833 "will present an overwrite confirmation dialog "
836 GTK_PARAM_READWRITE));
839 * GtkFileChooser:create-folders:
841 * Whether a file chooser not in %GTK_FILE_CHOOSER_ACTION_OPEN mode
842 * will offer the user to create new folders.
846 g_object_interface_install_property (g_iface,
847 g_param_spec_boolean ("create-folders",
848 P_("Allow folders creation"),
849 P_("Whether a file chooser not in open mode "
850 "will offer the user to create new folders."),
852 GTK_PARAM_READWRITE));
856 * gtk_file_chooser_error_quark:
858 * Registers an error quark for #GtkFileChooser if necessary.
860 * Return value: The error quark used for #GtkFileChooser errors.
865 gtk_file_chooser_error_quark (void)
867 return g_quark_from_static_string ("gtk-file-chooser-error-quark");
871 * gtk_file_chooser_set_action:
872 * @chooser: a #GtkFileChooser
873 * @action: the action that the file selector is performing
875 * Sets the type of operation that the chooser is performing; the
876 * user interface is adapted to suit the selected action. For example,
877 * an option to create a new folder might be shown if the action is
878 * %GTK_FILE_CHOOSER_ACTION_SAVE but not if the action is
879 * %GTK_FILE_CHOOSER_ACTION_OPEN.
884 gtk_file_chooser_set_action (GtkFileChooser *chooser,
885 GtkFileChooserAction action)
887 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
889 g_object_set (chooser, "action", action, NULL);
893 * gtk_file_chooser_get_action:
894 * @chooser: a #GtkFileChooser
896 * Gets the type of operation that the file chooser is performing; see
897 * gtk_file_chooser_set_action().
899 * Return value: the action that the file selector is performing
904 gtk_file_chooser_get_action (GtkFileChooser *chooser)
906 GtkFileChooserAction action;
908 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
910 g_object_get (chooser, "action", &action, NULL);
916 * gtk_file_chooser_set_local_only:
917 * @chooser: a #GtkFileChooser
918 * @local_only: %TRUE if only local files can be selected
920 * Sets whether only local files can be selected in the
921 * file selector. If @local_only is %TRUE (the default),
922 * then the selected file are files are guaranteed to be
923 * accessible through the operating systems native file
924 * file system and therefore the application only
925 * needs to worry about the filename functions in
926 * #GtkFileChooser, like gtk_file_chooser_get_filename(),
927 * rather than the URI functions like
928 * gtk_file_chooser_get_uri(),
933 gtk_file_chooser_set_local_only (GtkFileChooser *chooser,
936 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
938 g_object_set (chooser, "local-only", local_only, NULL);
942 * gtk_file_chooser_get_local_only:
943 * @chooser: a #GtkFileChoosre
945 * Gets whether only local files can be selected in the
946 * file selector. See gtk_file_chooser_set_local_only()
948 * Return value: %TRUE if only local files can be selected.
953 gtk_file_chooser_get_local_only (GtkFileChooser *chooser)
957 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
959 g_object_get (chooser, "local-only", &local_only, NULL);
965 * gtk_file_chooser_set_select_multiple:
966 * @chooser: a #GtkFileChooser
967 * @select_multiple: %TRUE if multiple files can be selected.
969 * Sets whether multiple files can be selected in the file selector. This is
970 * only relevant if the action is set to be %GTK_FILE_CHOOSER_ACTION_OPEN or
971 * %GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER.
976 gtk_file_chooser_set_select_multiple (GtkFileChooser *chooser,
977 gboolean select_multiple)
979 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
981 g_object_set (chooser, "select-multiple", select_multiple, NULL);
985 * gtk_file_chooser_get_select_multiple:
986 * @chooser: a #GtkFileChooser
988 * Gets whether multiple files can be selected in the file
989 * selector. See gtk_file_chooser_set_select_multiple().
991 * Return value: %TRUE if multiple files can be selected.
996 gtk_file_chooser_get_select_multiple (GtkFileChooser *chooser)
998 gboolean select_multiple;
1000 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1002 g_object_get (chooser, "select-multiple", &select_multiple, NULL);
1004 return select_multiple;
1008 * gtk_file_chooser_set_create_folders:
1009 * @chooser: a #GtkFileChooser
1010 * @create_folders: %TRUE if the New Folder button should be displayed
1012 * Sets whether file choser will offer to create new folders.
1013 * This is only relevant if the action is not set to be
1014 * %GTK_FILE_CHOOSER_ACTION_OPEN.
1019 gtk_file_chooser_set_create_folders (GtkFileChooser *chooser,
1020 gboolean create_folders)
1022 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1024 g_object_set (chooser, "create-folders", create_folders, NULL);
1028 * gtk_file_chooser_get_create_folders:
1029 * @chooser: a #GtkFileChooser
1031 * Gets whether file choser will offer to create new folders.
1032 * See gtk_file_chooser_set_create_folders().
1034 * Return value: %TRUE if the New Folder button should be displayed.
1039 gtk_file_chooser_get_create_folders (GtkFileChooser *chooser)
1041 gboolean create_folders;
1043 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1045 g_object_get (chooser, "create-folders", &create_folders, NULL);
1047 return create_folders;
1051 * gtk_file_chooser_get_filename:
1052 * @chooser: a #GtkFileChooser
1054 * Gets the filename for the currently selected file in
1055 * the file selector. If multiple files are selected,
1056 * one of the filenames will be returned at random.
1058 * If the file chooser is in folder mode, this function returns the selected
1061 * Return value: The currently selected filename, or %NULL
1062 * if no file is selected, or the selected file can't
1063 * be represented with a local filename. Free with g_free().
1068 gtk_file_chooser_get_filename (GtkFileChooser *chooser)
1071 gchar *result = NULL;
1073 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1075 file = gtk_file_chooser_get_file (chooser);
1079 result = g_file_get_path (file);
1080 g_object_unref (file);
1087 * gtk_file_chooser_set_filename:
1088 * @chooser: a #GtkFileChooser
1089 * @filename: the filename to set as current
1091 * Sets @filename as the current filename for the file chooser, by changing
1092 * to the file's parent folder and actually selecting the file in list. If
1093 * the @chooser is in %GTK_FILE_CHOOSER_ACTION_SAVE mode, the file's base name
1094 * will also appear in the dialog's file name entry.
1096 * If the file name isn't in the current folder of @chooser, then the current
1097 * folder of @chooser will be changed to the folder containing @filename. This
1098 * is equivalent to a sequence of gtk_file_chooser_unselect_all() followed by
1099 * gtk_file_chooser_select_filename().
1101 * Note that the file must exist, or nothing will be done except
1102 * for the directory change.
1104 * If you are implementing a <guimenuitem>File/Save As...</guimenuitem> dialog,
1105 * you should use this function if you already have a file name to which the
1106 * user may save; for example, when the user opens an existing file and then
1107 * does <guimenuitem>File/Save As...</guimenuitem> on it. If you don't have
1108 * a file name already — for example, if the user just created a new
1109 * file and is saving it for the first time, do not call this function.
1110 * Instead, use something similar to this:
1112 * if (document_is_new)
1114 * /* the user just created a new document */
1115 * gtk_file_chooser_set_current_folder (chooser, default_folder_for_saving);
1116 * gtk_file_chooser_set_current_name (chooser, "Untitled document");
1120 * /* the user edited an existing document */
1121 * gtk_file_chooser_set_filename (chooser, existing_filename);
1125 * Return value: %TRUE if both the folder could be changed and the file was
1126 * selected successfully, %FALSE otherwise.
1131 gtk_file_chooser_set_filename (GtkFileChooser *chooser,
1132 const gchar *filename)
1134 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1136 gtk_file_chooser_unselect_all (chooser);
1137 return gtk_file_chooser_select_filename (chooser, filename);
1141 * gtk_file_chooser_select_filename:
1142 * @chooser: a #GtkFileChooser
1143 * @filename: the filename to select
1145 * Selects a filename. If the file name isn't in the current
1146 * folder of @chooser, then the current folder of @chooser will
1147 * be changed to the folder containing @filename.
1149 * Return value: %TRUE if both the folder could be changed and the file was
1150 * selected successfully, %FALSE otherwise.
1155 gtk_file_chooser_select_filename (GtkFileChooser *chooser,
1156 const gchar *filename)
1161 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1162 g_return_val_if_fail (filename != NULL, FALSE);
1164 file = g_file_new_for_path (filename);
1165 result = gtk_file_chooser_select_file (chooser, file, NULL);
1166 g_object_unref (file);
1172 * gtk_file_chooser_unselect_filename:
1173 * @chooser: a #GtkFileChooser
1174 * @filename: the filename to unselect
1176 * Unselects a currently selected filename. If the filename
1177 * is not in the current directory, does not exist, or
1178 * is otherwise not currently selected, does nothing.
1183 gtk_file_chooser_unselect_filename (GtkFileChooser *chooser,
1184 const char *filename)
1188 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1189 g_return_if_fail (filename != NULL);
1191 file = g_file_new_for_path (filename);
1192 gtk_file_chooser_unselect_file (chooser, file);
1193 g_object_unref (file);
1196 /* Converts a list of GFile* to a list of strings using the specified function */
1198 files_to_strings (GSList *files,
1199 gchar * (*convert_func) (GFile *file))
1205 for (; files; files = files->next)
1211 string = (* convert_func) (file);
1214 strings = g_slist_prepend (strings, string);
1217 return g_slist_reverse (strings);
1221 * gtk_file_chooser_get_filenames:
1222 * @chooser: a #GtkFileChooser
1224 * Lists all the selected files and subfolders in the current folder of
1225 * @chooser. The returned names are full absolute paths. If files in the current
1226 * folder cannot be represented as local filenames they will be ignored. (See
1227 * gtk_file_chooser_get_uris())
1229 * Return value: (element-type utf8) (transfer full): a #GSList containing the filenames of all selected
1230 * files and subfolders in the current folder. Free the returned list
1231 * with g_slist_free(), and the filenames with g_free().
1236 gtk_file_chooser_get_filenames (GtkFileChooser *chooser)
1238 GSList *files, *result;
1240 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1242 files = gtk_file_chooser_get_files (chooser);
1244 result = files_to_strings (files, g_file_get_path);
1245 g_slist_foreach (files, (GFunc) g_object_unref, NULL);
1246 g_slist_free (files);
1252 * gtk_file_chooser_set_current_folder:
1253 * @chooser: a #GtkFileChooser
1254 * @filename: the full path of the new current folder
1256 * Sets the current folder for @chooser from a local filename.
1257 * The user will be shown the full contents of the current folder,
1258 * plus user interface elements for navigating to other folders.
1260 * Return value: %TRUE if the folder could be changed successfully, %FALSE
1266 gtk_file_chooser_set_current_folder (GtkFileChooser *chooser,
1267 const gchar *filename)
1272 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1273 g_return_val_if_fail (filename != NULL, FALSE);
1275 file = g_file_new_for_path (filename);
1276 result = gtk_file_chooser_set_current_folder_file (chooser, file, NULL);
1277 g_object_unref (file);
1283 * gtk_file_chooser_get_current_folder:
1284 * @chooser: a #GtkFileChooser
1286 * Gets the current folder of @chooser as a local filename.
1287 * See gtk_file_chooser_set_current_folder().
1289 * Note that this is the folder that the file chooser is currently displaying
1290 * (e.g. "/home/username/Documents"), which is <emphasis>not the same</emphasis>
1291 * as the currently-selected folder if the chooser is in
1292 * %GTK_FILE_CHOOSER_SELECT_FOLDER mode
1293 * (e.g. "/home/username/Documents/selected-folder/". To get the
1294 * currently-selected folder in that mode, use gtk_file_chooser_get_uri() as the
1295 * usual way to get the selection.
1297 * Return value: the full path of the current folder, or %NULL if the current
1298 * path cannot be represented as a local filename. Free with g_free(). This
1299 * function will also return %NULL if the file chooser was unable to load the
1300 * last folder that was requested from it; for example, as would be for calling
1301 * gtk_file_chooser_set_current_folder() on a nonexistent folder.
1306 gtk_file_chooser_get_current_folder (GtkFileChooser *chooser)
1311 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1313 file = gtk_file_chooser_get_current_folder_file (chooser);
1317 filename = g_file_get_path (file);
1318 g_object_unref (file);
1324 * gtk_file_chooser_set_current_name:
1325 * @chooser: a #GtkFileChooser
1326 * @name: the filename to use, as a UTF-8 string
1328 * Sets the current name in the file selector, as if entered
1329 * by the user. Note that the name passed in here is a UTF-8
1330 * string rather than a filename. This function is meant for
1331 * such uses as a suggested name in a "Save As..." dialog.
1333 * If you want to preselect a particular existing file, you should use
1334 * gtk_file_chooser_set_filename() or gtk_file_chooser_set_uri() instead.
1335 * Please see the documentation for those functions for an example of using
1336 * gtk_file_chooser_set_current_name() as well.
1341 gtk_file_chooser_set_current_name (GtkFileChooser *chooser,
1344 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1345 g_return_if_fail (name != NULL);
1347 GTK_FILE_CHOOSER_GET_IFACE (chooser)->set_current_name (chooser, name);
1351 * gtk_file_chooser_get_uri:
1352 * @chooser: a #GtkFileChooser
1354 * Gets the URI for the currently selected file in
1355 * the file selector. If multiple files are selected,
1356 * one of the filenames will be returned at random.
1358 * If the file chooser is in folder mode, this function returns the selected
1361 * Return value: The currently selected URI, or %NULL
1362 * if no file is selected. Free with g_free()
1367 gtk_file_chooser_get_uri (GtkFileChooser *chooser)
1370 gchar *result = NULL;
1372 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1374 file = gtk_file_chooser_get_file (chooser);
1377 result = g_file_get_uri (file);
1378 g_object_unref (file);
1385 * gtk_file_chooser_set_uri:
1386 * @chooser: a #GtkFileChooser
1387 * @uri: the URI to set as current
1389 * Sets the file referred to by @uri as the current file for the file chooser,
1390 * by changing to the URI's parent folder and actually selecting the URI in the
1391 * list. If the @chooser is %GTK_FILE_CHOOSER_ACTION_SAVE mode, the URI's base
1392 * name will also appear in the dialog's file name entry.
1394 * If the URI isn't in the current folder of @chooser, then the current folder
1395 * of @chooser will be changed to the folder containing @uri. This is equivalent
1396 * to a sequence of gtk_file_chooser_unselect_all() followed by
1397 * gtk_file_chooser_select_uri().
1399 * Note that the URI must exist, or nothing will be done except for the
1401 * If you are implementing a <guimenuitem>File/Save As...</guimenuitem> dialog,
1402 * you should use this function if you already have a file name to which the
1403 * user may save; for example, when the user opens an existing file and then
1404 * does <guimenuitem>File/Save As...</guimenuitem> on it. If you don't have
1405 * a file name already — for example, if the user just created a new
1406 * file and is saving it for the first time, do not call this function.
1407 * Instead, use something similar to this:
1409 * if (document_is_new)
1411 * /* the user just created a new document */
1412 * gtk_file_chooser_set_current_folder_uri (chooser, default_folder_for_saving);
1413 * gtk_file_chooser_set_current_name (chooser, "Untitled document");
1417 * /* the user edited an existing document */
1418 * gtk_file_chooser_set_uri (chooser, existing_uri);
1422 * Return value: %TRUE if both the folder could be changed and the URI was
1423 * selected successfully, %FALSE otherwise.
1428 gtk_file_chooser_set_uri (GtkFileChooser *chooser,
1431 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1433 gtk_file_chooser_unselect_all (chooser);
1434 return gtk_file_chooser_select_uri (chooser, uri);
1438 * gtk_file_chooser_select_uri:
1439 * @chooser: a #GtkFileChooser
1440 * @uri: the URI to select
1442 * Selects the file to by @uri. If the URI doesn't refer to a
1443 * file in the current folder of @chooser, then the current folder of
1444 * @chooser will be changed to the folder containing @filename.
1446 * Return value: %TRUE if both the folder could be changed and the URI was
1447 * selected successfully, %FALSE otherwise.
1452 gtk_file_chooser_select_uri (GtkFileChooser *chooser,
1458 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1459 g_return_val_if_fail (uri != NULL, FALSE);
1461 file = g_file_new_for_uri (uri);
1462 result = gtk_file_chooser_select_file (chooser, file, NULL);
1463 g_object_unref (file);
1469 * gtk_file_chooser_unselect_uri:
1470 * @chooser: a #GtkFileChooser
1471 * @uri: the URI to unselect
1473 * Unselects the file referred to by @uri. If the file
1474 * is not in the current directory, does not exist, or
1475 * is otherwise not currently selected, does nothing.
1480 gtk_file_chooser_unselect_uri (GtkFileChooser *chooser,
1485 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1486 g_return_if_fail (uri != NULL);
1488 file = g_file_new_for_uri (uri);
1489 gtk_file_chooser_unselect_file (chooser, file);
1490 g_object_unref (file);
1494 * gtk_file_chooser_select_all:
1495 * @chooser: a #GtkFileChooser
1497 * Selects all the files in the current folder of a file chooser.
1502 gtk_file_chooser_select_all (GtkFileChooser *chooser)
1504 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1506 GTK_FILE_CHOOSER_GET_IFACE (chooser)->select_all (chooser);
1510 * gtk_file_chooser_unselect_all:
1511 * @chooser: a #GtkFileChooser
1513 * Unselects all the files in the current folder of a file chooser.
1518 gtk_file_chooser_unselect_all (GtkFileChooser *chooser)
1521 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1523 GTK_FILE_CHOOSER_GET_IFACE (chooser)->unselect_all (chooser);
1527 * gtk_file_chooser_get_uris:
1528 * @chooser: a #GtkFileChooser
1530 * Lists all the selected files and subfolders in the current folder of
1531 * @chooser. The returned names are full absolute URIs.
1533 * Return value: (element-type utf8) (transfer full): a #GSList containing the URIs of all selected
1534 * files and subfolders in the current folder. Free the returned list
1535 * with g_slist_free(), and the filenames with g_free().
1540 gtk_file_chooser_get_uris (GtkFileChooser *chooser)
1542 GSList *files, *result;
1544 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1546 files = gtk_file_chooser_get_files (chooser);
1548 result = files_to_strings (files, g_file_get_uri);
1549 g_slist_foreach (files, (GFunc) g_object_unref, NULL);
1550 g_slist_free (files);
1556 * gtk_file_chooser_set_current_folder_uri:
1557 * @chooser: a #GtkFileChooser
1558 * @uri: the URI for the new current folder
1560 * Sets the current folder for @chooser from an URI.
1561 * The user will be shown the full contents of the current folder,
1562 * plus user interface elements for navigating to other folders.
1564 * Return value: %TRUE if the folder could be changed successfully, %FALSE
1570 gtk_file_chooser_set_current_folder_uri (GtkFileChooser *chooser,
1576 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1577 g_return_val_if_fail (uri != NULL, FALSE);
1579 file = g_file_new_for_uri (uri);
1580 result = gtk_file_chooser_set_current_folder_file (chooser, file, NULL);
1581 g_object_unref (file);
1587 * gtk_file_chooser_get_current_folder_uri:
1588 * @chooser: a #GtkFileChooser
1590 * Gets the current folder of @chooser as an URI.
1591 * See gtk_file_chooser_set_current_folder_uri().
1593 * Note that this is the folder that the file chooser is currently displaying
1594 * (e.g. "file:///home/username/Documents"), which is <emphasis>not the same</emphasis>
1595 * as the currently-selected folder if the chooser is in
1596 * %GTK_FILE_CHOOSER_SELECT_FOLDER mode
1597 * (e.g. "file:///home/username/Documents/selected-folder/". To get the
1598 * currently-selected folder in that mode, use gtk_file_chooser_get_uri() as the
1599 * usual way to get the selection.
1601 * Return value: the URI for the current folder. Free with g_free(). This
1602 * function will also return %NULL if the file chooser was unable to load the
1603 * last folder that was requested from it; for example, as would be for calling
1604 * gtk_file_chooser_set_current_folder_uri() on a nonexistent folder.
1609 gtk_file_chooser_get_current_folder_uri (GtkFileChooser *chooser)
1614 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1616 file = gtk_file_chooser_get_current_folder_file (chooser);
1620 uri = g_file_get_uri (file);
1621 g_object_unref (file);
1627 * gtk_file_chooser_set_current_folder_file:
1628 * @chooser: a #GtkFileChooser
1629 * @file: the #GFile for the new folder
1630 * @error: (allow-none): location to store error, or %NULL.
1632 * Sets the current folder for @chooser from a #GFile.
1633 * Internal function, see gtk_file_chooser_set_current_folder_uri().
1635 * Return value: %TRUE if the folder could be changed successfully, %FALSE
1641 gtk_file_chooser_set_current_folder_file (GtkFileChooser *chooser,
1645 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1646 g_return_val_if_fail (G_IS_FILE (file), FALSE);
1647 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
1649 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->set_current_folder (chooser, file, error);
1653 * gtk_file_chooser_get_current_folder_file:
1654 * @chooser: a #GtkFileChooser
1656 * Gets the current folder of @chooser as #GFile.
1657 * See gtk_file_chooser_get_current_folder_uri().
1659 * Return value: the #GFile for the current folder.
1664 gtk_file_chooser_get_current_folder_file (GtkFileChooser *chooser)
1666 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1668 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_current_folder (chooser);
1672 * gtk_file_chooser_select_file:
1673 * @chooser: a #GtkFileChooser
1674 * @file: the file to select
1675 * @error: (allow-none): location to store error, or %NULL
1677 * Selects the file referred to by @file. An internal function. See
1678 * _gtk_file_chooser_select_uri().
1680 * Return value: %TRUE if both the folder could be changed and the path was
1681 * selected successfully, %FALSE otherwise.
1686 gtk_file_chooser_select_file (GtkFileChooser *chooser,
1690 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1691 g_return_val_if_fail (G_IS_FILE (file), FALSE);
1692 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
1694 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->select_file (chooser, file, error);
1698 * gtk_file_chooser_unselect_file:
1699 * @chooser: a #GtkFileChooser
1702 * Unselects the file referred to by @file. If the file is not in the current
1703 * directory, does not exist, or is otherwise not currently selected, does nothing.
1708 gtk_file_chooser_unselect_file (GtkFileChooser *chooser,
1711 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1712 g_return_if_fail (G_IS_FILE (file));
1714 GTK_FILE_CHOOSER_GET_IFACE (chooser)->unselect_file (chooser, file);
1718 * gtk_file_chooser_get_files:
1719 * @chooser: a #GtkFileChooser
1721 * Lists all the selected files and subfolders in the current folder of @chooser
1722 * as #GFile. An internal function, see gtk_file_chooser_get_uris().
1724 * Return value: (element-type utf8) (transfer full): a #GSList containing a #GFile for each selected
1725 * file and subfolder in the current folder. Free the returned list
1726 * with g_slist_free(), and the files with g_object_unref().
1731 gtk_file_chooser_get_files (GtkFileChooser *chooser)
1733 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1735 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_files (chooser);
1739 * gtk_file_chooser_set_file:
1740 * @chooser: a #GtkFileChooser
1741 * @file: the #GFile to set as current
1742 * @error: (allow-none): location to store the error, or %NULL to ignore errors.
1744 * Sets @file as the current filename for the file chooser, by changing
1745 * to the file's parent folder and actually selecting the file in list. If
1746 * the @chooser is in %GTK_FILE_CHOOSER_ACTION_SAVE mode, the file's base name
1747 * will also appear in the dialog's file name entry.
1749 * If the file name isn't in the current folder of @chooser, then the current
1750 * folder of @chooser will be changed to the folder containing @filename. This
1751 * is equivalent to a sequence of gtk_file_chooser_unselect_all() followed by
1752 * gtk_file_chooser_select_filename().
1754 * Note that the file must exist, or nothing will be done except
1755 * for the directory change.
1757 * If you are implementing a <guimenuitem>File/Save As...</guimenuitem> dialog,
1758 * you should use this function if you already have a file name to which the
1759 * user may save; for example, when the user opens an existing file and then
1760 * does <guimenuitem>File/Save As...</guimenuitem> on it. If you don't have
1761 * a file name already — for example, if the user just created a new
1762 * file and is saving it for the first time, do not call this function.
1763 * Instead, use something similar to this:
1765 * if (document_is_new)
1767 * /* the user just created a new document */
1768 * gtk_file_chooser_set_current_folder_file (chooser, default_file_for_saving);
1769 * gtk_file_chooser_set_current_name (chooser, "Untitled document");
1773 * /* the user edited an existing document */
1774 * gtk_file_chooser_set_file (chooser, existing_file);
1778 * Return value: %TRUE if both the folder could be changed and the file was
1779 * selected successfully, %FALSE otherwise.
1784 gtk_file_chooser_set_file (GtkFileChooser *chooser,
1788 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1789 g_return_val_if_fail (G_IS_FILE (file), FALSE);
1790 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
1792 gtk_file_chooser_unselect_all (chooser);
1793 return gtk_file_chooser_select_file (chooser, file, error);
1797 * gtk_file_chooser_get_file:
1798 * @chooser: a #GtkFileChooser
1800 * Gets the #GFile for the currently selected file in
1801 * the file selector. If multiple files are selected,
1802 * one of the files will be returned at random.
1804 * If the file chooser is in folder mode, this function returns the selected
1807 * Returns: a selected #GFile. You own the returned file; use
1808 * g_object_unref() to release it.
1813 gtk_file_chooser_get_file (GtkFileChooser *chooser)
1816 GFile *result = NULL;
1818 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1820 list = gtk_file_chooser_get_files (chooser);
1823 result = list->data;
1824 list = g_slist_delete_link (list, list);
1826 g_slist_foreach (list, (GFunc) g_object_unref, NULL);
1827 g_slist_free (list);
1834 * _gtk_file_chooser_get_file_system:
1835 * @chooser: a #GtkFileChooser
1837 * Gets the #GtkFileSystem of @chooser; this is an internal
1838 * implementation detail, used for conversion between paths
1839 * and filenames and URIs.
1841 * Return value: the file system for @chooser.
1846 _gtk_file_chooser_get_file_system (GtkFileChooser *chooser)
1848 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1850 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_file_system (chooser);
1856 * gtk_file_chooser_set_preview_widget:
1857 * @chooser: a #GtkFileChooser
1858 * @preview_widget: widget for displaying preview.
1860 * Sets an application-supplied widget to use to display a custom preview
1861 * of the currently selected file. To implement a preview, after setting the
1862 * preview widget, you connect to the #GtkFileChooser::update-preview
1863 * signal, and call gtk_file_chooser_get_preview_filename() or
1864 * gtk_file_chooser_get_preview_uri() on each change. If you can
1865 * display a preview of the new file, update your widget and
1866 * set the preview active using gtk_file_chooser_set_preview_widget_active().
1867 * Otherwise, set the preview inactive.
1869 * When there is no application-supplied preview widget, or the
1870 * application-supplied preview widget is not active, the file chooser
1871 * may display an internally generated preview of the current file or
1872 * it may display no preview at all.
1877 gtk_file_chooser_set_preview_widget (GtkFileChooser *chooser,
1878 GtkWidget *preview_widget)
1880 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1882 g_object_set (chooser, "preview-widget", preview_widget, NULL);
1886 * gtk_file_chooser_get_preview_widget:
1887 * @chooser: a #GtkFileChooser
1889 * Gets the current preview widget; see
1890 * gtk_file_chooser_set_preview_widget().
1892 * Return value: the current preview widget, or %NULL
1897 gtk_file_chooser_get_preview_widget (GtkFileChooser *chooser)
1899 GtkWidget *preview_widget;
1901 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1903 g_object_get (chooser, "preview-widget", &preview_widget, NULL);
1905 /* Horrid hack; g_object_get() refs returned objects but
1906 * that contradicts the memory management conventions
1910 g_object_unref (preview_widget);
1912 return preview_widget;
1916 * gtk_file_chooser_set_preview_widget_active:
1917 * @chooser: a #GtkFileChooser
1918 * @active: whether to display the user-specified preview widget
1920 * Sets whether the preview widget set by
1921 * gtk_file_chooser_set_preview_widget() should be shown for the
1922 * current filename. When @active is set to false, the file chooser
1923 * may display an internally generated preview of the current file
1924 * or it may display no preview at all. See
1925 * gtk_file_chooser_set_preview_widget() for more details.
1930 gtk_file_chooser_set_preview_widget_active (GtkFileChooser *chooser,
1933 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1935 g_object_set (chooser, "preview-widget-active", active, NULL);
1939 * gtk_file_chooser_get_preview_widget_active:
1940 * @chooser: a #GtkFileChooser
1942 * Gets whether the preview widget set by gtk_file_chooser_set_preview_widget()
1943 * should be shown for the current filename. See
1944 * gtk_file_chooser_set_preview_widget_active().
1946 * Return value: %TRUE if the preview widget is active for the current filename.
1951 gtk_file_chooser_get_preview_widget_active (GtkFileChooser *chooser)
1955 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1957 g_object_get (chooser, "preview-widget-active", &active, NULL);
1963 * gtk_file_chooser_set_use_preview_label:
1964 * @chooser: a #GtkFileChooser
1965 * @use_label: whether to display a stock label with the name of the previewed file
1967 * Sets whether the file chooser should display a stock label with the name of
1968 * the file that is being previewed; the default is %TRUE. Applications that
1969 * want to draw the whole preview area themselves should set this to %FALSE and
1970 * display the name themselves in their preview widget.
1972 * See also: gtk_file_chooser_set_preview_widget()
1977 gtk_file_chooser_set_use_preview_label (GtkFileChooser *chooser,
1980 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1982 g_object_set (chooser, "use-preview-label", use_label, NULL);
1986 * gtk_file_chooser_get_use_preview_label:
1987 * @chooser: a #GtkFileChooser
1989 * Gets whether a stock label should be drawn with the name of the previewed
1990 * file. See gtk_file_chooser_set_use_preview_label().
1992 * Return value: %TRUE if the file chooser is set to display a label with the
1993 * name of the previewed file, %FALSE otherwise.
1996 gtk_file_chooser_get_use_preview_label (GtkFileChooser *chooser)
2000 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2002 g_object_get (chooser, "use-preview-label", &use_label, NULL);
2008 * gtk_file_chooser_get_preview_file:
2009 * @chooser: a #GtkFileChooser
2011 * Gets the #GFile that should be previewed in a custom preview
2012 * Internal function, see gtk_file_chooser_get_preview_uri().
2014 * Return value: the #GFile for the file to preview, or %NULL if no file
2015 * is selected. Free with g_object_unref().
2020 gtk_file_chooser_get_preview_file (GtkFileChooser *chooser)
2022 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2024 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_preview_file (chooser);
2028 * _gtk_file_chooser_add_shortcut_folder:
2029 * @chooser: a #GtkFileChooser
2030 * @file: file for the folder to add
2031 * @error: (allow-none): location to store error, or %NULL
2033 * Adds a folder to be displayed with the shortcut folders in a file chooser.
2034 * Internal function, see gtk_file_chooser_add_shortcut_folder().
2036 * Return value: %TRUE if the folder could be added successfully, %FALSE
2042 _gtk_file_chooser_add_shortcut_folder (GtkFileChooser *chooser,
2046 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2047 g_return_val_if_fail (G_IS_FILE (file), FALSE);
2049 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_shortcut_folder (chooser, file, error);
2053 * _gtk_file_chooser_remove_shortcut_folder:
2054 * @chooser: a #GtkFileChooser
2055 * @file: file for the folder to remove
2056 * @error: (allow-none): location to store error, or %NULL
2058 * Removes a folder from the shortcut folders in a file chooser. Internal
2059 * function, see gtk_file_chooser_remove_shortcut_folder().
2061 * Return value: %TRUE if the folder could be removed successfully, %FALSE
2067 _gtk_file_chooser_remove_shortcut_folder (GtkFileChooser *chooser,
2071 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2072 g_return_val_if_fail (G_IS_FILE (file), FALSE);
2074 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_shortcut_folder (chooser, file, error);
2078 * gtk_file_chooser_get_preview_filename:
2079 * @chooser: a #GtkFileChooser
2081 * Gets the filename that should be previewed in a custom preview
2082 * widget. See gtk_file_chooser_set_preview_widget().
2084 * Return value: the filename to preview, or %NULL if no file
2085 * is selected, or if the selected file cannot be represented
2086 * as a local filename. Free with g_free()
2091 gtk_file_chooser_get_preview_filename (GtkFileChooser *chooser)
2094 gchar *result = NULL;
2096 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2098 file = gtk_file_chooser_get_preview_file (chooser);
2101 result = g_file_get_path (file);
2102 g_object_unref (file);
2109 * gtk_file_chooser_get_preview_uri:
2110 * @chooser: a #GtkFileChooser
2112 * Gets the URI that should be previewed in a custom preview
2113 * widget. See gtk_file_chooser_set_preview_widget().
2115 * Return value: the URI for the file to preview, or %NULL if no file is
2116 * selected. Free with g_free().
2121 gtk_file_chooser_get_preview_uri (GtkFileChooser *chooser)
2124 gchar *result = NULL;
2126 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2128 file = gtk_file_chooser_get_preview_file (chooser);
2131 result = g_file_get_uri (file);
2132 g_object_unref (file);
2139 * gtk_file_chooser_set_extra_widget:
2140 * @chooser: a #GtkFileChooser
2141 * @extra_widget: widget for extra options
2143 * Sets an application-supplied widget to provide extra options to the user.
2148 gtk_file_chooser_set_extra_widget (GtkFileChooser *chooser,
2149 GtkWidget *extra_widget)
2151 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
2153 g_object_set (chooser, "extra-widget", extra_widget, NULL);
2157 * gtk_file_chooser_get_extra_widget:
2158 * @chooser: a #GtkFileChooser
2160 * Gets the current preview widget; see
2161 * gtk_file_chooser_set_extra_widget().
2163 * Return value: the current extra widget, or %NULL
2168 gtk_file_chooser_get_extra_widget (GtkFileChooser *chooser)
2170 GtkWidget *extra_widget;
2172 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2174 g_object_get (chooser, "extra-widget", &extra_widget, NULL);
2176 /* Horrid hack; g_object_get() refs returned objects but
2177 * that contradicts the memory management conventions
2181 g_object_unref (extra_widget);
2183 return extra_widget;
2187 * gtk_file_chooser_add_filter:
2188 * @chooser: a #GtkFileChooser
2189 * @filter: a #GtkFileFilter
2191 * Adds @filter to the list of filters that the user can select between.
2192 * When a filter is selected, only files that are passed by that
2193 * filter are displayed.
2195 * Note that the @chooser takes ownership of the filter, so you have to
2196 * ref and sink it if you want to keep a reference.
2201 gtk_file_chooser_add_filter (GtkFileChooser *chooser,
2202 GtkFileFilter *filter)
2204 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
2206 GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_filter (chooser, filter);
2210 * gtk_file_chooser_remove_filter:
2211 * @chooser: a #GtkFileChooser
2212 * @filter: a #GtkFileFilter
2214 * Removes @filter from the list of filters that the user can select between.
2219 gtk_file_chooser_remove_filter (GtkFileChooser *chooser,
2220 GtkFileFilter *filter)
2222 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
2224 GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_filter (chooser, filter);
2228 * gtk_file_chooser_list_filters:
2229 * @chooser: a #GtkFileChooser
2231 * Lists the current set of user-selectable filters; see
2232 * gtk_file_chooser_add_filter(), gtk_file_chooser_remove_filter().
2234 * Return value: (element-type utf8) (transfer container): a #GSList containing the current set of
2235 * user selectable filters. The contents of the list are
2236 * owned by GTK+, but you must free the list itself with
2237 * g_slist_free() when you are done with it.
2242 gtk_file_chooser_list_filters (GtkFileChooser *chooser)
2244 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2246 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->list_filters (chooser);
2250 * gtk_file_chooser_set_filter:
2251 * @chooser: a #GtkFileChooser
2252 * @filter: a #GtkFileFilter
2254 * Sets the current filter; only the files that pass the
2255 * filter will be displayed. If the user-selectable list of filters
2256 * is non-empty, then the filter should be one of the filters
2257 * in that list. Setting the current filter when the list of
2258 * filters is empty is useful if you want to restrict the displayed
2259 * set of files without letting the user change it.
2264 gtk_file_chooser_set_filter (GtkFileChooser *chooser,
2265 GtkFileFilter *filter)
2267 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
2268 g_return_if_fail (GTK_IS_FILE_FILTER (filter));
2270 g_object_set (chooser, "filter", filter, NULL);
2274 * gtk_file_chooser_get_filter:
2275 * @chooser: a #GtkFileChooser
2277 * Gets the current filter; see gtk_file_chooser_set_filter().
2279 * Return value: the current filter, or %NULL
2284 gtk_file_chooser_get_filter (GtkFileChooser *chooser)
2286 GtkFileFilter *filter;
2288 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2290 g_object_get (chooser, "filter", &filter, NULL);
2291 /* Horrid hack; g_object_get() refs returned objects but
2292 * that contradicts the memory management conventions
2296 g_object_unref (filter);
2302 * gtk_file_chooser_add_shortcut_folder:
2303 * @chooser: a #GtkFileChooser
2304 * @folder: filename of the folder to add
2305 * @error: (allow-none): location to store error, or %NULL
2307 * Adds a folder to be displayed with the shortcut folders in a file chooser.
2308 * Note that shortcut folders do not get saved, as they are provided by the
2309 * application. For example, you can use this to add a
2310 * "/usr/share/mydrawprogram/Clipart" folder to the volume list.
2312 * Return value: %TRUE if the folder could be added successfully, %FALSE
2313 * otherwise. In the latter case, the @error will be set as appropriate.
2318 gtk_file_chooser_add_shortcut_folder (GtkFileChooser *chooser,
2325 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2326 g_return_val_if_fail (folder != NULL, FALSE);
2328 file = g_file_new_for_path (folder);
2329 result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_shortcut_folder (chooser, file, error);
2330 g_object_unref (file);
2336 * gtk_file_chooser_remove_shortcut_folder:
2337 * @chooser: a #GtkFileChooser
2338 * @folder: filename of the folder to remove
2339 * @error: (allow-none): location to store error, or %NULL
2341 * Removes a folder from a file chooser's list of shortcut folders.
2343 * Return value: %TRUE if the operation succeeds, %FALSE otherwise.
2344 * In the latter case, the @error will be set as appropriate.
2346 * See also: gtk_file_chooser_add_shortcut_folder()
2351 gtk_file_chooser_remove_shortcut_folder (GtkFileChooser *chooser,
2358 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2359 g_return_val_if_fail (folder != NULL, FALSE);
2361 file = g_file_new_for_path (folder);
2362 result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_shortcut_folder (chooser, file, error);
2363 g_object_unref (file);
2369 * gtk_file_chooser_list_shortcut_folders:
2370 * @chooser: a #GtkFileChooser
2372 * Queries the list of shortcut folders in the file chooser, as set by
2373 * gtk_file_chooser_add_shortcut_folder().
2375 * Return value: (element-type utf8) (transfer full): A list of folder filenames, or %NULL if there are no shortcut
2376 * folders. Free the returned list with g_slist_free(), and the filenames with
2382 gtk_file_chooser_list_shortcut_folders (GtkFileChooser *chooser)
2387 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2389 folders = _gtk_file_chooser_list_shortcut_folder_files (chooser);
2391 result = files_to_strings (folders, g_file_get_path);
2392 g_slist_foreach (folders, (GFunc) g_object_unref, NULL);
2393 g_slist_free (folders);
2399 * gtk_file_chooser_add_shortcut_folder_uri:
2400 * @chooser: a #GtkFileChooser
2401 * @uri: URI of the folder to add
2402 * @error: (allow-none): location to store error, or %NULL
2404 * Adds a folder URI to be displayed with the shortcut folders in a file
2405 * chooser. Note that shortcut folders do not get saved, as they are provided
2406 * by the application. For example, you can use this to add a
2407 * "file:///usr/share/mydrawprogram/Clipart" folder to the volume list.
2409 * Return value: %TRUE if the folder could be added successfully, %FALSE
2410 * otherwise. In the latter case, the @error will be set as appropriate.
2415 gtk_file_chooser_add_shortcut_folder_uri (GtkFileChooser *chooser,
2422 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2423 g_return_val_if_fail (uri != NULL, FALSE);
2425 file = g_file_new_for_uri (uri);
2426 result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_shortcut_folder (chooser, file, error);
2427 g_object_unref (file);
2433 * gtk_file_chooser_remove_shortcut_folder_uri:
2434 * @chooser: a #GtkFileChooser
2435 * @uri: URI of the folder to remove
2436 * @error: (allow-none): location to store error, or %NULL
2438 * Removes a folder URI from a file chooser's list of shortcut folders.
2440 * Return value: %TRUE if the operation succeeds, %FALSE otherwise.
2441 * In the latter case, the @error will be set as appropriate.
2443 * See also: gtk_file_chooser_add_shortcut_folder_uri()
2448 gtk_file_chooser_remove_shortcut_folder_uri (GtkFileChooser *chooser,
2455 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2456 g_return_val_if_fail (uri != NULL, FALSE);
2458 file = g_file_new_for_uri (uri);
2459 result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_shortcut_folder (chooser, file, error);
2460 g_object_unref (file);
2466 * gtk_file_chooser_list_shortcut_folder_uris:
2467 * @chooser: a #GtkFileChooser
2469 * Queries the list of shortcut folders in the file chooser, as set by
2470 * gtk_file_chooser_add_shortcut_folder_uri().
2472 * Return value: (element-type utf8) (transfer full): A list of folder URIs, or %NULL if there are no shortcut
2473 * folders. Free the returned list with g_slist_free(), and the URIs with
2479 gtk_file_chooser_list_shortcut_folder_uris (GtkFileChooser *chooser)
2484 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2486 folders = _gtk_file_chooser_list_shortcut_folder_files (chooser);
2488 result = files_to_strings (folders, g_file_get_uri);
2489 g_slist_foreach (folders, (GFunc) g_object_unref, NULL);
2490 g_slist_free (folders);
2496 _gtk_file_chooser_list_shortcut_folder_files (GtkFileChooser *chooser)
2498 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2500 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->list_shortcut_folders (chooser);
2504 * gtk_file_chooser_set_show_hidden:
2505 * @chooser: a #GtkFileChooser
2506 * @show_hidden: %TRUE if hidden files and folders should be displayed.
2508 * Sets whether hidden files and folders are displayed in the file selector.
2513 gtk_file_chooser_set_show_hidden (GtkFileChooser *chooser,
2514 gboolean show_hidden)
2516 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
2518 g_object_set (chooser, "show-hidden", show_hidden, NULL);
2522 * gtk_file_chooser_get_show_hidden:
2523 * @chooser: a #GtkFileChooser
2525 * Gets whether hidden files and folders are displayed in the file selector.
2526 * See gtk_file_chooser_set_show_hidden().
2528 * Return value: %TRUE if hidden files and folders are displayed.
2533 gtk_file_chooser_get_show_hidden (GtkFileChooser *chooser)
2535 gboolean show_hidden;
2537 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2539 g_object_get (chooser, "show-hidden", &show_hidden, NULL);
2545 * gtk_file_chooser_set_do_overwrite_confirmation:
2546 * @chooser: a #GtkFileChooser
2547 * @do_overwrite_confirmation: whether to confirm overwriting in save mode
2549 * Sets whether a file chooser in %GTK_FILE_CHOOSER_ACTION_SAVE mode will present
2550 * a confirmation dialog if the user types a file name that already exists. This
2551 * is %FALSE by default.
2553 * Regardless of this setting, the @chooser will emit the
2554 * #GtkFileChooser::confirm-overwrite signal when appropriate.
2556 * If all you need is the stock confirmation dialog, set this property to %TRUE.
2557 * You can override the way confirmation is done by actually handling the
2558 * #GtkFileChooser::confirm-overwrite signal; please refer to its documentation
2564 gtk_file_chooser_set_do_overwrite_confirmation (GtkFileChooser *chooser,
2565 gboolean do_overwrite_confirmation)
2567 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
2569 g_object_set (chooser, "do-overwrite-confirmation", do_overwrite_confirmation, NULL);
2573 * gtk_file_chooser_get_do_overwrite_confirmation:
2574 * @chooser: a #GtkFileChooser
2576 * Queries whether a file chooser is set to confirm for overwriting when the user
2577 * types a file name that already exists.
2579 * Return value: %TRUE if the file chooser will present a confirmation dialog;
2585 gtk_file_chooser_get_do_overwrite_confirmation (GtkFileChooser *chooser)
2587 gboolean do_overwrite_confirmation;
2589 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2591 g_object_get (chooser, "do-overwrite-confirmation", &do_overwrite_confirmation, NULL);
2593 return do_overwrite_confirmation;
2596 #if defined (G_OS_WIN32) && !defined (_WIN64)
2598 /* DLL ABI stability backward compatibility versions */
2600 #undef gtk_file_chooser_get_filename
2603 gtk_file_chooser_get_filename (GtkFileChooser *chooser)
2605 gchar *utf8_filename = gtk_file_chooser_get_filename_utf8 (chooser);
2606 gchar *retval = g_locale_from_utf8 (utf8_filename, -1, NULL, NULL, NULL);
2608 g_free (utf8_filename);
2613 #undef gtk_file_chooser_set_filename
2616 gtk_file_chooser_set_filename (GtkFileChooser *chooser,
2617 const gchar *filename)
2619 gchar *utf8_filename = g_locale_to_utf8 (filename, -1, NULL, NULL, NULL);
2620 gboolean retval = gtk_file_chooser_set_filename_utf8 (chooser, utf8_filename);
2622 g_free (utf8_filename);
2627 #undef gtk_file_chooser_select_filename
2630 gtk_file_chooser_select_filename (GtkFileChooser *chooser,
2631 const gchar *filename)
2633 gchar *utf8_filename = g_locale_to_utf8 (filename, -1, NULL, NULL, NULL);
2634 gboolean retval = gtk_file_chooser_select_filename_utf8 (chooser, utf8_filename);
2636 g_free (utf8_filename);
2641 #undef gtk_file_chooser_unselect_filename
2644 gtk_file_chooser_unselect_filename (GtkFileChooser *chooser,
2645 const char *filename)
2647 gchar *utf8_filename = g_locale_to_utf8 (filename, -1, NULL, NULL, NULL);
2649 gtk_file_chooser_unselect_filename_utf8 (chooser, utf8_filename);
2650 g_free (utf8_filename);
2653 #undef gtk_file_chooser_get_filenames
2656 gtk_file_chooser_get_filenames (GtkFileChooser *chooser)
2658 GSList *list = gtk_file_chooser_get_filenames_utf8 (chooser);
2659 GSList *rover = list;
2663 gchar *tem = (gchar *) rover->data;
2664 rover->data = g_locale_from_utf8 ((gchar *) rover->data, -1, NULL, NULL, NULL);
2666 rover = rover->next;
2672 #undef gtk_file_chooser_set_current_folder
2675 gtk_file_chooser_set_current_folder (GtkFileChooser *chooser,
2676 const gchar *filename)
2678 gchar *utf8_filename = g_locale_to_utf8 (filename, -1, NULL, NULL, NULL);
2679 gboolean retval = gtk_file_chooser_set_current_folder_utf8 (chooser, utf8_filename);
2681 g_free (utf8_filename);
2686 #undef gtk_file_chooser_get_current_folder
2689 gtk_file_chooser_get_current_folder (GtkFileChooser *chooser)
2691 gchar *utf8_folder = gtk_file_chooser_get_current_folder_utf8 (chooser);
2692 gchar *retval = g_locale_from_utf8 (utf8_folder, -1, NULL, NULL, NULL);
2694 g_free (utf8_folder);
2699 #undef gtk_file_chooser_get_preview_filename
2702 gtk_file_chooser_get_preview_filename (GtkFileChooser *chooser)
2704 char *utf8_filename = gtk_file_chooser_get_preview_filename_utf8 (chooser);
2705 char *retval = g_locale_from_utf8 (utf8_filename, -1, NULL, NULL, NULL);
2707 g_free (utf8_filename);
2712 #undef gtk_file_chooser_add_shortcut_folder
2715 gtk_file_chooser_add_shortcut_folder (GtkFileChooser *chooser,
2719 char *utf8_folder = g_locale_to_utf8 (folder, -1, NULL, NULL, NULL);
2721 gtk_file_chooser_add_shortcut_folder_utf8 (chooser, utf8_folder, error);
2723 g_free (utf8_folder);
2728 #undef gtk_file_chooser_remove_shortcut_folder
2731 gtk_file_chooser_remove_shortcut_folder (GtkFileChooser *chooser,
2735 char *utf8_folder = g_locale_to_utf8 (folder, -1, NULL, NULL, NULL);
2737 gtk_file_chooser_remove_shortcut_folder_utf8 (chooser, utf8_folder, error);
2739 g_free (utf8_folder);
2744 #undef gtk_file_chooser_list_shortcut_folders
2747 gtk_file_chooser_list_shortcut_folders (GtkFileChooser *chooser)
2749 GSList *list = gtk_file_chooser_list_shortcut_folders_utf8 (chooser);
2750 GSList *rover = list;
2754 gchar *tem = (gchar *) rover->data;
2755 rover->data = g_locale_from_utf8 ((gchar *) rover->data, -1, NULL, NULL, NULL);
2757 rover = rover->next;
2765 #define __GTK_FILE_CHOOSER_C__
2766 #include "gtkaliasdef.c"