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.
75 * <refsect2 id="gtkfilechooser-encodings">
76 * <title>File Names and Encodings</title>
77 * When the user is finished selecting files in a
78 * #GtkFileChooser, your program can get the selected names
79 * either as filenames or as URIs. For URIs, the normal escaping
80 * rules are applied if the URI contains non-ASCII characters.
81 * However, filenames are <emphasis>always</emphasis> returned in
82 * the character set specified by the
83 * <envar>G_FILENAME_ENCODING</envar> environment variable.
84 * Please see the Glib documentation for more details about this
87 * This means that while you can pass the result of
88 * gtk_file_chooser_get_filename() to
89 * <function>open(2)</function> or
90 * <function>fopen(3)</function>, you may not be able to
91 * directly set it as the text of a #GtkLabel widget unless you
92 * convert it first to UTF-8, which all GTK+ widgets expect.
93 * You should use g_filename_to_utf8() to convert filenames
94 * into strings that can be passed to GTK+ widgets.
97 * <refsect2 id="gtkfilechooser-preview">
98 * <title>Adding a Preview Widget</title>
100 * You can add a custom preview widget to a file chooser and then
101 * get notification about when the preview needs to be updated.
102 * To install a preview widget, use
103 * gtk_file_chooser_set_preview_widget(). Then, connect to the
104 * #GtkFileChooser::update-preview signal to get notified when
105 * you need to update the contents of the preview.
108 * Your callback should use
109 * gtk_file_chooser_get_preview_filename() to see what needs
110 * previewing. Once you have generated the preview for the
111 * corresponding file, you must call
112 * gtk_file_chooser_set_preview_widget_active() with a boolean
113 * flag that indicates whether your callback could successfully
114 * generate a preview.
116 * <example id="example-gtkfilechooser-preview">
117 * <title>Sample Usage</title>
124 * preview = gtk_image_new (<!-- -->);
126 * gtk_file_chooser_set_preview_widget (my_file_chooser, preview);
127 * g_signal_connect (my_file_chooser, "update-preview",
128 * G_CALLBACK (update_preview_cb), preview);
132 * update_preview_cb (GtkFileChooser *file_chooser, gpointer data)
134 * GtkWidget *preview;
137 * gboolean have_preview;
139 * preview = GTK_WIDGET (data);
140 * filename = gtk_file_chooser_get_preview_filename (file_chooser);
142 * pixbuf = gdk_pixbuf_new_from_file_at_size (filename, 128, 128, NULL);
143 * have_preview = (pixbuf != NULL);
146 * gtk_image_set_from_pixbuf (GTK_IMAGE (preview), pixbuf);
148 * g_object_unref (pixbuf);
150 * gtk_file_chooser_set_preview_widget_active (file_chooser, have_preview);
155 * <refsect2 id="gtkfilechooser-extra">
156 * <title>Adding Extra Widgets</title>
158 * You can add extra widgets to a file chooser to provide options
159 * that are not present in the default design. For example, you
160 * can add a toggle button to give the user the option to open a
161 * file in read-only mode. You can use
162 * gtk_file_chooser_set_extra_widget() to insert additional
163 * widgets in a file chooser.
165 * <example id="example-gtkfilechooser-extra">
166 * <title>Sample Usage</title>
173 * toggle = gtk_check_button_new_with_label ("Open file read-only");
174 * gtk_widget_show (toggle);
175 * gtk_file_chooser_set_extra_widget (my_file_chooser, toggle);
180 * If you want to set more than one extra widget in the file
181 * chooser, you can a container such as a #GtkVBox or a #GtkTable
182 * and include your widgets in it. Then, set the container as
183 * the whole extra widget.
186 * <refsect2 id="gtkfilechooser-key-bindings">
187 * <title>Key Bindings</title>
189 * Internally, GTK+ implements a file chooser's graphical user
190 * interface with the private
191 * <classname>GtkFileChooserDefaultClass</classname>. This
192 * widget has several <link linkend="gtk-Bindings">key
193 * bindings</link> and their associated signals. This section
194 * describes the available key binding signals.
196 * <example id="gtkfilechooser-key-binding-example">
197 * <title>GtkFileChooser key binding example</title>
199 * The default keys that activate the key-binding signals in
200 * <classname>GtkFileChooserDefaultClass</classname> are as
207 * <entry>Signal name</entry>
208 * <entry>Default key combinations</entry>
211 * <entry>location-popup</entry>
213 * <keycombo><keycap>Control</keycap><keycap>L</keycap></keycombo> (empty path);
214 * <keycap>/</keycap> (path of "/")
216 * Both the individual <keycap>/</keycap> key and the
217 * numeric keypad's "divide" key are supported.
219 * <keycap>~</keycap> (path of "~")
223 * <entry>up-folder</entry>
225 * <keycombo><keycap>Alt</keycap><keycap>Up</keycap></keycombo>
227 * Both the individual Up key and the numeric
228 * keypad's Up key are supported.
231 * <keycap>Backspace</keycap>
235 * <entry>down-folder</entry>
236 * <entry><keycombo><keycap>Alt</keycap><keycap>Down</keycap></keycombo></entry>
239 * <entry>home-folder</entry>
240 * <entry><keycombo><keycap>Alt</keycap><keycap>Home</keycap></keycombo></entry>
243 * <entry>desktop-folder</entry>
244 * <entry><keycombo><keycap>Alt</keycap><keycap>D</keycap></keycombo></entry>
247 * <entry>quick-bookmark</entry>
248 * <entry><keycombo><keycap>Alt</keycap><keycap>1</keycap></keycombo> through <keycombo><keycap>Alt</keycap><keycap>0</keycap></keycombo></entry>
254 * You can change these defaults to something else. For
255 * example, to add a <keycap>Shift</keycap> modifier to a few
256 * of the default bindings, you can include the following
257 * fragment in your <filename>.gtkrc-2.0</filename> file:
260 * binding "my-own-gtkfilechooser-bindings" {
261 * bind "<Alt><Shift>Up" {
264 * bind "<Alt><Shift>Down" {
267 * bind "<Alt><Shift>Home" {
272 * class "GtkFileChooserDefault" binding "my-own-gtkfilechooser-bindings"
275 * <refsect3 id="GtkFileChooserDefault-location-popup">
276 * <title>The "GtkFileChooserDefault::location-popup" signal</title>
278 * void user_function (GtkFileChooserDefault *chooser,
280 * <link linkend="gpointer">gpointer</link> user_data);
283 * This is used to make the file chooser show a "Location"
284 * dialog which the user can use to manually type the name of
285 * the file he wishes to select. The
286 * <parameter>path</parameter> argument is a string that gets
287 * put in the text entry for the file name. By default this is bound to
288 * <keycombo><keycap>Control</keycap><keycap>L</keycap></keycombo>
289 * with a <parameter>path</parameter> string of "" (the empty
290 * string). It is also bound to <keycap>/</keycap> with a
291 * <parameter>path</parameter> string of "<literal>/</literal>"
292 * (a slash): this lets you type <keycap>/</keycap> and
293 * immediately type a path name. On Unix systems, this is bound to
294 * <keycap>~</keycap> (tilde) with a <parameter>path</parameter> string
295 * of "~" itself for access to home directories.
297 * <variablelist role="params">
299 * <term><parameter>chooser</parameter> :</term>
302 * the object which received the signal.
307 * <term><parameter>path</parameter> :</term>
310 * default contents for the text entry for the file name
315 * <term><parameter>user_data</parameter> :</term>
318 * user data set when the signal handler was connected.
324 * You can create your own bindings for the
325 * GtkFileChooserDefault::location-popup signal with custom
326 * <parameter>path</parameter> strings, and have a crude form
327 * of easily-to-type bookmarks. For example, say you access
328 * the path <filename>/home/username/misc</filename> very
329 * frequently. You could then create an <keycombo>
330 * <keycap>Alt</keycap> <keycap>M</keycap> </keycombo>
331 * shortcut by including the following in your
332 * <filename>.gtkrc-2.0</filename>:
334 * binding "misc-shortcut" {
335 * bind "<Alt>M" {
336 * "location-popup" ("/home/username/misc")
340 * class "GtkFileChooserDefault" binding "misc-shortcut"
344 * <refsect3 id="GtkFileChooserDefault-up-folder">
345 * <title>The "GtkFileChooserDefault::up-folder" signal</title>
347 * void user_function (GtkFileChooserDefault *chooser,
348 * <link linkend="gpointer">gpointer</link> user_data);
351 * This is used to make the file chooser go to the parent of
352 * the current folder in the file hierarchy. By default this
353 * is bound to <keycap>Backspace</keycap> and
354 * <keycombo><keycap>Alt</keycap><keycap>Up</keycap></keycombo>
355 * (the Up key in the numeric keypad also works).
357 * <variablelist role="params">
359 * <term><parameter>chooser</parameter> :</term>
362 * the object which received the signal.
367 * <term><parameter>user_data</parameter> :</term>
370 * user data set when the signal handler was connected.
376 * <refsect3 id="GtkFileChooserDefault-down-folder">
377 * <title>The "GtkFileChooserDefault::down-folder" signal</title>
379 * void user_function (GtkFileChooserDefault *chooser,
380 * <link linkend="gpointer">gpointer</link> user_data);
383 * This is used to make the file chooser go to a child of the
384 * current folder in the file hierarchy. The subfolder that
385 * will be used is displayed in the path bar widget of the file
386 * chooser. For example, if the path bar is showing
387 * "/foo/<emphasis>bar/</emphasis>baz", then this will cause
388 * the file chooser to switch to the "baz" subfolder. By
389 * default this is bound to
390 * <keycombo><keycap>Alt</keycap><keycap>Down</keycap></keycombo>
391 * (the Down key in the numeric keypad also works).
393 * <variablelist role="params">
395 * <term><parameter>chooser</parameter> :</term>
398 * the object which received the signal.
403 * <term><parameter>user_data</parameter> :</term>
406 * user data set when the signal handler was connected.
412 * <refsect3 id="GtkFileChooserDefault-home-folder">
413 * <title>The "GtkFileChooserDefault::home-folder" signal</title>
415 * void user_function (GtkFileChooserDefault *chooser,
416 * <link linkend="gpointer">gpointer</link> user_data);
419 * This is used to make the file chooser show the user's home
420 * folder in the file list. By default this is bound to
421 * <keycombo><keycap>Alt</keycap><keycap>Home</keycap></keycombo>
422 * (the Home key in the numeric keypad also works).
424 * <variablelist role="params">
426 * <term><parameter>chooser</parameter> :</term>
429 * the object which received the signal.
434 * <term><parameter>user_data</parameter> :</term>
437 * user data set when the signal handler was connected.
443 * <refsect3 id="GtkFileChooserDefault-desktop-folder">
444 * <title>The "GtkFileChooserDefault::desktop-folder" signal</title>
446 * void user_function (GtkFileChooserDefault *chooser,
447 * <link linkend="gpointer">gpointer</link> user_data);
450 * This is used to make the file chooser show the user's Desktop
451 * folder in the file list. By default this is bound to
452 * <keycombo><keycap>Alt</keycap><keycap>D</keycap></keycombo>.
454 * <variablelist role="params">
456 * <term><parameter>chooser</parameter> :</term>
459 * the object which received the signal.
464 * <term><parameter>user_data</parameter> :</term>
467 * user data set when the signal handler was connected.
473 * <refsect3 id="GtkFileChooserDefault-quick-bookmark">
474 * <title>The "GtkFileChooserDefault::quick-bookmark" signal</title>
476 * void user_function (GtkFileChooserDefault *chooser,
477 * gint bookmark_index,
478 * <link linkend="gpointer">gpointer</link> user_data);
481 * This is used to make the file chooser switch to the bookmark
482 * specified in the <parameter>bookmark_index</parameter> parameter.
483 * For example, if you have three bookmarks, you can pass 0, 1, 2 to
484 * this signal to switch to each of them, respectively. By default this is bound to
485 * <keycombo><keycap>Alt</keycap><keycap>1</keycap></keycombo>,
486 * <keycombo><keycap>Alt</keycap><keycap>2</keycap></keycombo>,
488 * <keycombo><keycap>Alt</keycap><keycap>0</keycap></keycombo>. Note
489 * that in the default binding,
490 * that <keycombo><keycap>Alt</keycap><keycap>1</keycap></keycombo> is
491 * actually defined to switch to the bookmark at index 0, and so on
493 * <keycombo><keycap>Alt</keycap><keycap>0</keycap></keycombo> is
494 * defined to switch to the bookmark at index 10.
496 * <variablelist role="params">
498 * <term><parameter>chooser</parameter> :</term>
501 * the object which received the signal.
506 * <term><parameter>bookmark_indes</parameter> :</term>
509 * index of the bookmark to switch to; the indices start at 0.
514 * <term><parameter>user_data</parameter> :</term>
517 * user data set when the signal handler was connected.
527 static void gtk_file_chooser_class_init (gpointer g_iface);
530 gtk_file_chooser_get_type (void)
532 static GType file_chooser_type = 0;
534 if (!file_chooser_type)
536 file_chooser_type = g_type_register_static_simple (G_TYPE_INTERFACE,
537 I_("GtkFileChooser"),
538 sizeof (GtkFileChooserIface),
539 (GClassInitFunc) gtk_file_chooser_class_init,
542 g_type_interface_add_prerequisite (file_chooser_type, GTK_TYPE_WIDGET);
545 return file_chooser_type;
549 confirm_overwrite_accumulator (GSignalInvocationHint *ihint,
551 const GValue *handler_return,
554 gboolean continue_emission;
555 GtkFileChooserConfirmation conf;
557 conf = g_value_get_enum (handler_return);
558 g_value_set_enum (return_accu, conf);
559 continue_emission = (conf == GTK_FILE_CHOOSER_CONFIRMATION_CONFIRM);
561 return continue_emission;
565 gtk_file_chooser_class_init (gpointer g_iface)
567 GType iface_type = G_TYPE_FROM_INTERFACE (g_iface);
570 * GtkFileChooser::current-folder-changed
571 * @chooser: the object which received the signal.
573 * This signal is emitted when the current folder in a #GtkFileChooser
574 * changes. This can happen due to the user performing some action that
575 * changes folders, such as selecting a bookmark or visiting a folder on the
576 * file list. It can also happen as a result of calling a function to
577 * explicitly change the current folder in a file chooser.
579 * Normally you do not need to connect to this signal, unless you need to keep
580 * track of which folder a file chooser is showing.
582 * See also: gtk_file_chooser_set_current_folder(),
583 * gtk_file_chooser_get_current_folder(),
584 * gtk_file_chooser_set_current_folder_uri(),
585 * gtk_file_chooser_get_current_folder_uri().
587 g_signal_new (I_("current-folder-changed"),
590 G_STRUCT_OFFSET (GtkFileChooserIface, current_folder_changed),
592 g_cclosure_marshal_VOID__VOID,
596 * GtkFileChooser::selection-changed
597 * @chooser: the object which received the signal.
599 * This signal is emitted when there is a change in the set of selected files
600 * in a #GtkFileChooser. This can happen when the user modifies the selection
601 * with the mouse or the keyboard, or when explicitly calling functions to
602 * change the selection.
604 * Normally you do not need to connect to this signal, as it is easier to wait
605 * for the file chooser to finish running, and then to get the list of
606 * selected files using the functions mentioned below.
608 * See also: gtk_file_chooser_select_filename(),
609 * gtk_file_chooser_unselect_filename(), gtk_file_chooser_get_filename(),
610 * gtk_file_chooser_get_filenames(), gtk_file_chooser_select_uri(),
611 * gtk_file_chooser_unselect_uri(), gtk_file_chooser_get_uri(),
612 * gtk_file_chooser_get_uris().
614 g_signal_new (I_("selection-changed"),
617 G_STRUCT_OFFSET (GtkFileChooserIface, selection_changed),
619 g_cclosure_marshal_VOID__VOID,
623 * GtkFileChooser::update-preview
624 * @chooser: the object which received the signal.
626 * This signal is emitted when the preview in a file chooser should be
627 * regenerated. For example, this can happen when the currently selected file
628 * changes. You should use this signal if you want your file chooser to have
631 * Once you have installed a preview widget with
632 * gtk_file_chooser_set_preview_widget(), you should update it when this
633 * signal is emitted. You can use the functions
634 * gtk_file_chooser_get_preview_filename() or
635 * gtk_file_chooser_get_preview_uri() to get the name of the file to preview.
636 * Your widget may not be able to preview all kinds of files; your callback
637 * must call gtk_file_chooser_set_preview_widget_active() to inform the file
638 * chooser about whether the preview was generated successfully or not.
640 * Please see the example code in <xref linkend="gtkfilechooser-preview"/>.
642 * See also: gtk_file_chooser_set_preview_widget(),
643 * gtk_file_chooser_set_preview_widget_active(),
644 * gtk_file_chooser_set_use_preview_label(),
645 * gtk_file_chooser_get_preview_filename(),
646 * gtk_file_chooser_get_preview_uri().
648 g_signal_new (I_("update-preview"),
651 G_STRUCT_OFFSET (GtkFileChooserIface, update_preview),
653 g_cclosure_marshal_VOID__VOID,
657 * GtkFileChooser::file-activated
658 * @chooser: the object which received the signal.
660 * This signal is emitted when the user "activates" a file in the file
661 * chooser. This can happen by double-clicking on a file in the file list, or
662 * by pressing <keycap>Enter</keycap>.
664 * Normally you do not need to connect to this signal. It is used internally
665 * by #GtkFileChooserDialog to know when to activate the default button in the
668 * See also: gtk_file_chooser_get_filename(),
669 * gtk_file_chooser_get_filenames(), gtk_file_chooser_get_uri(),
670 * gtk_file_chooser_get_uris().
672 g_signal_new (I_("file-activated"),
675 G_STRUCT_OFFSET (GtkFileChooserIface, file_activated),
677 g_cclosure_marshal_VOID__VOID,
681 * GtkFileChooser::confirm-overwrite:
682 * @chooser: the object which received the signal.
684 * This signal gets emitted whenever it is appropriate to present a
685 * confirmation dialog when the user has selected a file name that
686 * already exists. The signal only gets emitted when the file
687 * chooser is in %GTK_FILE_CHOOSER_ACTION_SAVE mode.
689 * Most applications just need to turn on the
690 * #GtkFileChooser:do-overwrite-confirmation property (or call the
691 * gtk_file_chooser_set_do_overwrite_confirmation() function), and
692 * they will automatically get a stock confirmation dialog.
693 * Applications which need to customize this behavior should do
694 * that, and also connect to the #GtkFileChooser::confirm-overwrite
697 * A signal handler for this signal must return a
698 * #GtkFileChooserConfirmation value, which indicates the action to
699 * take. If the handler determines that the user wants to select a
700 * different filename, it should return
701 * %GTK_FILE_CHOOSER_CONFIRMATION_SELECT_AGAIN. If it determines
702 * that the user is satisfied with his choice of file name, it
703 * should return %GTK_FILE_CHOOSER_CONFIRMATION_ACCEPT_FILENAME.
704 * On the other hand, if it determines that the stock confirmation
705 * dialog should be used, it should return
706 * %GTK_FILE_CHOOSER_CONFIRMATION_CONFIRM. The following example
708 * <example id="gtkfilechooser-confirmation">
709 * <title>Custom confirmation</title>
711 * static GtkFileChooserConfirmation
712 * confirm_overwrite_callback (GtkFileChooser *chooser, gpointer data)
716 * uri = gtk_file_chooser_get_uri (chooser);
718 * if (is_uri_read_only (uri))
720 * if (user_wants_to_replace_read_only_file (uri))
721 * return GTK_FILE_CHOOSER_CONFIRMATION_ACCEPT_FILENAME;
723 * return GTK_FILE_CHOOSER_CONFIRMATION_SELECT_AGAIN;
725 * return GTK_FILE_CHOOSER_CONFIRMATION_CONFIRM; // fall back to the default dialog
730 * chooser = gtk_file_chooser_dialog_new (...);
732 * gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), TRUE);
733 * g_signal_connect (chooser, "confirm-overwrite",
734 * G_CALLBACK (confirm_overwrite_callback), NULL);
736 * if (gtk_dialog_run (chooser) == GTK_RESPONSE_ACCEPT)
737 * save_to_file (gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (chooser));
739 * gtk_widget_destroy (chooser);
743 * Returns: a #GtkFileChooserConfirmation value that indicates which
744 * action to take after emitting the signal.
748 g_signal_new (I_("confirm-overwrite"),
751 G_STRUCT_OFFSET (GtkFileChooserIface, confirm_overwrite),
752 confirm_overwrite_accumulator, NULL,
753 _gtk_marshal_ENUM__VOID,
754 GTK_TYPE_FILE_CHOOSER_CONFIRMATION, 0);
756 g_object_interface_install_property (g_iface,
757 g_param_spec_enum ("action",
759 P_("The type of operation that the file selector is performing"),
760 GTK_TYPE_FILE_CHOOSER_ACTION,
761 GTK_FILE_CHOOSER_ACTION_OPEN,
762 GTK_PARAM_READWRITE));
763 g_object_interface_install_property (g_iface,
764 g_param_spec_string ("file-system-backend",
765 P_("File System Backend"),
766 P_("Name of file system backend to use"),
768 GTK_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
769 g_object_interface_install_property (g_iface,
770 g_param_spec_object ("filter",
772 P_("The current filter for selecting which files are displayed"),
773 GTK_TYPE_FILE_FILTER,
774 GTK_PARAM_READWRITE));
775 g_object_interface_install_property (g_iface,
776 g_param_spec_boolean ("local-only",
778 P_("Whether the selected file(s) should be limited to local file: URLs"),
780 GTK_PARAM_READWRITE));
781 g_object_interface_install_property (g_iface,
782 g_param_spec_object ("preview-widget",
783 P_("Preview widget"),
784 P_("Application supplied widget for custom previews."),
786 GTK_PARAM_READWRITE));
787 g_object_interface_install_property (g_iface,
788 g_param_spec_boolean ("preview-widget-active",
789 P_("Preview Widget Active"),
790 P_("Whether the application supplied widget for custom previews should be shown."),
792 GTK_PARAM_READWRITE));
793 g_object_interface_install_property (g_iface,
794 g_param_spec_boolean ("use-preview-label",
795 P_("Use Preview Label"),
796 P_("Whether to display a stock label with the name of the previewed file."),
798 GTK_PARAM_READWRITE));
799 g_object_interface_install_property (g_iface,
800 g_param_spec_object ("extra-widget",
802 P_("Application supplied widget for extra options."),
804 GTK_PARAM_READWRITE));
805 g_object_interface_install_property (g_iface,
806 g_param_spec_boolean ("select-multiple",
807 P_("Select Multiple"),
808 P_("Whether to allow multiple files to be selected"),
810 GTK_PARAM_READWRITE));
812 g_object_interface_install_property (g_iface,
813 g_param_spec_boolean ("show-hidden",
815 P_("Whether the hidden files and folders should be displayed"),
817 GTK_PARAM_READWRITE));
820 * GtkFileChooser:do-overwrite-confirmation:
822 * Whether a file chooser in %GTK_FILE_CHOOSER_ACTION_SAVE mode
823 * will present an overwrite confirmation dialog if the user
824 * selects a file name that already exists.
828 g_object_interface_install_property (g_iface,
829 g_param_spec_boolean ("do-overwrite-confirmation",
830 P_("Do overwrite confirmation"),
831 P_("Whether a file chooser in save mode "
832 "will present an overwrite confirmation dialog "
835 GTK_PARAM_READWRITE));
838 * GtkFileChooser:create-folders:
840 * Whether a file chooser not in %GTK_FILE_CHOOSER_ACTION_OPEN mode
841 * will offer the user to create new folders.
845 g_object_interface_install_property (g_iface,
846 g_param_spec_boolean ("create-folders",
847 P_("Allow folders creation"),
848 P_("Whether a file chooser not in open mode "
849 "will offer the user to create new folders."),
851 GTK_PARAM_READWRITE));
855 * gtk_file_chooser_error_quark:
857 * Registers an error quark for #GtkFileChooser if necessary.
859 * Return value: The error quark used for #GtkFileChooser errors.
864 gtk_file_chooser_error_quark (void)
866 return g_quark_from_static_string ("gtk-file-chooser-error-quark");
870 * gtk_file_chooser_set_action:
871 * @chooser: a #GtkFileChooser
872 * @action: the action that the file selector is performing
874 * Sets the type of operation that the chooser is performing; the
875 * user interface is adapted to suit the selected action. For example,
876 * an option to create a new folder might be shown if the action is
877 * %GTK_FILE_CHOOSER_ACTION_SAVE but not if the action is
878 * %GTK_FILE_CHOOSER_ACTION_OPEN.
883 gtk_file_chooser_set_action (GtkFileChooser *chooser,
884 GtkFileChooserAction action)
886 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
888 g_object_set (chooser, "action", action, NULL);
892 * gtk_file_chooser_get_action:
893 * @chooser: a #GtkFileChooser
895 * Gets the type of operation that the file chooser is performing; see
896 * gtk_file_chooser_set_action().
898 * Return value: the action that the file selector is performing
903 gtk_file_chooser_get_action (GtkFileChooser *chooser)
905 GtkFileChooserAction action;
907 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
909 g_object_get (chooser, "action", &action, NULL);
915 * gtk_file_chooser_set_local_only:
916 * @chooser: a #GtkFileChooser
917 * @local_only: %TRUE if only local files can be selected
919 * Sets whether only local files can be selected in the
920 * file selector. If @local_only is %TRUE (the default),
921 * then the selected file are files are guaranteed to be
922 * accessible through the operating systems native file
923 * file system and therefore the application only
924 * needs to worry about the filename functions in
925 * #GtkFileChooser, like gtk_file_chooser_get_filename(),
926 * rather than the URI functions like
927 * gtk_file_chooser_get_uri(),
932 gtk_file_chooser_set_local_only (GtkFileChooser *chooser,
935 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
937 g_object_set (chooser, "local-only", local_only, NULL);
941 * gtk_file_chooser_get_local_only:
942 * @chooser: a #GtkFileChoosre
944 * Gets whether only local files can be selected in the
945 * file selector. See gtk_file_chooser_set_local_only()
947 * Return value: %TRUE if only local files can be selected.
952 gtk_file_chooser_get_local_only (GtkFileChooser *chooser)
956 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
958 g_object_get (chooser, "local-only", &local_only, NULL);
964 * gtk_file_chooser_set_select_multiple:
965 * @chooser: a #GtkFileChooser
966 * @select_multiple: %TRUE if multiple files can be selected.
968 * Sets whether multiple files can be selected in the file selector. This is
969 * only relevant if the action is set to be %GTK_FILE_CHOOSER_ACTION_OPEN or
970 * %GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER.
975 gtk_file_chooser_set_select_multiple (GtkFileChooser *chooser,
976 gboolean select_multiple)
978 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
980 g_object_set (chooser, "select-multiple", select_multiple, NULL);
984 * gtk_file_chooser_get_select_multiple:
985 * @chooser: a #GtkFileChooser
987 * Gets whether multiple files can be selected in the file
988 * selector. See gtk_file_chooser_set_select_multiple().
990 * Return value: %TRUE if multiple files can be selected.
995 gtk_file_chooser_get_select_multiple (GtkFileChooser *chooser)
997 gboolean select_multiple;
999 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1001 g_object_get (chooser, "select-multiple", &select_multiple, NULL);
1003 return select_multiple;
1007 * gtk_file_chooser_set_create_folders:
1008 * @chooser: a #GtkFileChooser
1009 * @create_folders: %TRUE if the New Folder button should be displayed
1011 * Sets whether file choser will offer to create new folders.
1012 * This is only relevant if the action is not set to be
1013 * %GTK_FILE_CHOOSER_ACTION_OPEN.
1018 gtk_file_chooser_set_create_folders (GtkFileChooser *chooser,
1019 gboolean create_folders)
1021 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1023 g_object_set (chooser, "create-folders", create_folders, NULL);
1027 * gtk_file_chooser_get_create_folders:
1028 * @chooser: a #GtkFileChooser
1030 * Gets whether file choser will offer to create new folders.
1031 * See gtk_file_chooser_set_create_folders().
1033 * Return value: %TRUE if the New Folder button should be displayed.
1038 gtk_file_chooser_get_create_folders (GtkFileChooser *chooser)
1040 gboolean create_folders;
1042 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1044 g_object_get (chooser, "create-folders", &create_folders, NULL);
1046 return create_folders;
1050 * gtk_file_chooser_get_filename:
1051 * @chooser: a #GtkFileChooser
1053 * Gets the filename for the currently selected file in
1054 * the file selector. If multiple files are selected,
1055 * one of the filenames will be returned at random.
1057 * If the file chooser is in folder mode, this function returns the selected
1060 * Return value: The currently selected filename, or %NULL
1061 * if no file is selected, or the selected file can't
1062 * be represented with a local filename. Free with g_free().
1067 gtk_file_chooser_get_filename (GtkFileChooser *chooser)
1070 gchar *result = NULL;
1072 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1074 file = gtk_file_chooser_get_file (chooser);
1078 result = g_file_get_path (file);
1079 g_object_unref (file);
1086 * gtk_file_chooser_set_filename:
1087 * @chooser: a #GtkFileChooser
1088 * @filename: the filename to set as current
1090 * Sets @filename as the current filename for the file chooser, by changing
1091 * to the file's parent folder and actually selecting the file in list. If
1092 * the @chooser is in %GTK_FILE_CHOOSER_ACTION_SAVE mode, the file's base name
1093 * will also appear in the dialog's file name entry.
1095 * If the file name isn't in the current folder of @chooser, then the current
1096 * folder of @chooser will be changed to the folder containing @filename. This
1097 * is equivalent to a sequence of gtk_file_chooser_unselect_all() followed by
1098 * gtk_file_chooser_select_filename().
1100 * Note that the file must exist, or nothing will be done except
1101 * for the directory change.
1103 * If you are implementing a <guimenuitem>File/Save As...</guimenuitem> dialog,
1104 * you should use this function if you already have a file name to which the
1105 * user may save; for example, when the user opens an existing file and then
1106 * does <guimenuitem>File/Save As...</guimenuitem> on it. If you don't have
1107 * a file name already — for example, if the user just created a new
1108 * file and is saving it for the first time, do not call this function.
1109 * Instead, use something similar to this:
1111 * if (document_is_new)
1113 * /* the user just created a new document */
1114 * gtk_file_chooser_set_current_folder (chooser, default_folder_for_saving);
1115 * gtk_file_chooser_set_current_name (chooser, "Untitled document");
1119 * /* the user edited an existing document */
1120 * gtk_file_chooser_set_filename (chooser, existing_filename);
1124 * Return value: %TRUE if both the folder could be changed and the file was
1125 * selected successfully, %FALSE otherwise.
1130 gtk_file_chooser_set_filename (GtkFileChooser *chooser,
1131 const gchar *filename)
1133 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1135 gtk_file_chooser_unselect_all (chooser);
1136 return gtk_file_chooser_select_filename (chooser, filename);
1140 * gtk_file_chooser_select_filename:
1141 * @chooser: a #GtkFileChooser
1142 * @filename: the filename to select
1144 * Selects a filename. If the file name isn't in the current
1145 * folder of @chooser, then the current folder of @chooser will
1146 * be changed to the folder containing @filename.
1148 * Return value: %TRUE if both the folder could be changed and the file was
1149 * selected successfully, %FALSE otherwise.
1154 gtk_file_chooser_select_filename (GtkFileChooser *chooser,
1155 const gchar *filename)
1160 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1161 g_return_val_if_fail (filename != NULL, FALSE);
1163 file = g_file_new_for_path (filename);
1164 result = gtk_file_chooser_select_file (chooser, file, NULL);
1165 g_object_unref (file);
1171 * gtk_file_chooser_unselect_filename:
1172 * @chooser: a #GtkFileChooser
1173 * @filename: the filename to unselect
1175 * Unselects a currently selected filename. If the filename
1176 * is not in the current directory, does not exist, or
1177 * is otherwise not currently selected, does nothing.
1182 gtk_file_chooser_unselect_filename (GtkFileChooser *chooser,
1183 const char *filename)
1187 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1188 g_return_if_fail (filename != NULL);
1190 file = g_file_new_for_path (filename);
1191 gtk_file_chooser_unselect_file (chooser, file);
1192 g_object_unref (file);
1195 /* Converts a list of GFile* to a list of strings using the specified function */
1197 files_to_strings (GSList *files,
1198 gchar * (*convert_func) (GFile *file))
1204 for (; files; files = files->next)
1210 string = (* convert_func) (file);
1213 strings = g_slist_prepend (strings, string);
1216 return g_slist_reverse (strings);
1220 * gtk_file_chooser_get_filenames:
1221 * @chooser: a #GtkFileChooser
1223 * Lists all the selected files and subfolders in the current folder of
1224 * @chooser. The returned names are full absolute paths. If files in the current
1225 * folder cannot be represented as local filenames they will be ignored. (See
1226 * gtk_file_chooser_get_uris())
1228 * Return value: (element-type utf8) (transfer full): a #GSList containing the filenames of all selected
1229 * files and subfolders in the current folder. Free the returned list
1230 * with g_slist_free(), and the filenames with g_free().
1235 gtk_file_chooser_get_filenames (GtkFileChooser *chooser)
1237 GSList *files, *result;
1239 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1241 files = gtk_file_chooser_get_files (chooser);
1243 result = files_to_strings (files, g_file_get_path);
1244 g_slist_foreach (files, (GFunc) g_object_unref, NULL);
1245 g_slist_free (files);
1251 * gtk_file_chooser_set_current_folder:
1252 * @chooser: a #GtkFileChooser
1253 * @filename: the full path of the new current folder
1255 * Sets the current folder for @chooser from a local filename.
1256 * The user will be shown the full contents of the current folder,
1257 * plus user interface elements for navigating to other folders.
1259 * Return value: %TRUE if the folder could be changed successfully, %FALSE
1265 gtk_file_chooser_set_current_folder (GtkFileChooser *chooser,
1266 const gchar *filename)
1271 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1272 g_return_val_if_fail (filename != NULL, FALSE);
1274 file = g_file_new_for_path (filename);
1275 result = gtk_file_chooser_set_current_folder_file (chooser, file, NULL);
1276 g_object_unref (file);
1282 * gtk_file_chooser_get_current_folder:
1283 * @chooser: a #GtkFileChooser
1285 * Gets the current folder of @chooser as a local filename.
1286 * See gtk_file_chooser_set_current_folder().
1288 * Note that this is the folder that the file chooser is currently displaying
1289 * (e.g. "/home/username/Documents"), which is <emphasis>not the same</emphasis>
1290 * as the currently-selected folder if the chooser is in
1291 * %GTK_FILE_CHOOSER_SELECT_FOLDER mode
1292 * (e.g. "/home/username/Documents/selected-folder/". To get the
1293 * currently-selected folder in that mode, use gtk_file_chooser_get_uri() as the
1294 * usual way to get the selection.
1296 * Return value: the full path of the current folder, or %NULL if the current
1297 * path cannot be represented as a local filename. Free with g_free(). This
1298 * function will also return %NULL if the file chooser was unable to load the
1299 * last folder that was requested from it; for example, as would be for calling
1300 * gtk_file_chooser_set_current_folder() on a nonexistent folder.
1305 gtk_file_chooser_get_current_folder (GtkFileChooser *chooser)
1310 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1312 file = gtk_file_chooser_get_current_folder_file (chooser);
1316 filename = g_file_get_path (file);
1317 g_object_unref (file);
1323 * gtk_file_chooser_set_current_name:
1324 * @chooser: a #GtkFileChooser
1325 * @name: the filename to use, as a UTF-8 string
1327 * Sets the current name in the file selector, as if entered
1328 * by the user. Note that the name passed in here is a UTF-8
1329 * string rather than a filename. This function is meant for
1330 * such uses as a suggested name in a "Save As..." dialog.
1332 * If you want to preselect a particular existing file, you should use
1333 * gtk_file_chooser_set_filename() or gtk_file_chooser_set_uri() instead.
1334 * Please see the documentation for those functions for an example of using
1335 * gtk_file_chooser_set_current_name() as well.
1340 gtk_file_chooser_set_current_name (GtkFileChooser *chooser,
1343 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1344 g_return_if_fail (name != NULL);
1346 GTK_FILE_CHOOSER_GET_IFACE (chooser)->set_current_name (chooser, name);
1350 * gtk_file_chooser_get_uri:
1351 * @chooser: a #GtkFileChooser
1353 * Gets the URI for the currently selected file in
1354 * the file selector. If multiple files are selected,
1355 * one of the filenames will be returned at random.
1357 * If the file chooser is in folder mode, this function returns the selected
1360 * Return value: The currently selected URI, or %NULL
1361 * if no file is selected. Free with g_free()
1366 gtk_file_chooser_get_uri (GtkFileChooser *chooser)
1369 gchar *result = NULL;
1371 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1373 file = gtk_file_chooser_get_file (chooser);
1376 result = g_file_get_uri (file);
1377 g_object_unref (file);
1384 * gtk_file_chooser_set_uri:
1385 * @chooser: a #GtkFileChooser
1386 * @uri: the URI to set as current
1388 * Sets the file referred to by @uri as the current file for the file chooser,
1389 * by changing to the URI's parent folder and actually selecting the URI in the
1390 * list. If the @chooser is %GTK_FILE_CHOOSER_ACTION_SAVE mode, the URI's base
1391 * name will also appear in the dialog's file name entry.
1393 * If the URI isn't in the current folder of @chooser, then the current folder
1394 * of @chooser will be changed to the folder containing @uri. This is equivalent
1395 * to a sequence of gtk_file_chooser_unselect_all() followed by
1396 * gtk_file_chooser_select_uri().
1398 * Note that the URI must exist, or nothing will be done except for the
1400 * If you are implementing a <guimenuitem>File/Save As...</guimenuitem> dialog,
1401 * you should use this function if you already have a file name to which the
1402 * user may save; for example, when the user opens an existing file and then
1403 * does <guimenuitem>File/Save As...</guimenuitem> on it. If you don't have
1404 * a file name already — for example, if the user just created a new
1405 * file and is saving it for the first time, do not call this function.
1406 * Instead, use something similar to this:
1408 * if (document_is_new)
1410 * /* the user just created a new document */
1411 * gtk_file_chooser_set_current_folder_uri (chooser, default_folder_for_saving);
1412 * gtk_file_chooser_set_current_name (chooser, "Untitled document");
1416 * /* the user edited an existing document */
1417 * gtk_file_chooser_set_uri (chooser, existing_uri);
1421 * Return value: %TRUE if both the folder could be changed and the URI was
1422 * selected successfully, %FALSE otherwise.
1427 gtk_file_chooser_set_uri (GtkFileChooser *chooser,
1430 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1432 gtk_file_chooser_unselect_all (chooser);
1433 return gtk_file_chooser_select_uri (chooser, uri);
1437 * gtk_file_chooser_select_uri:
1438 * @chooser: a #GtkFileChooser
1439 * @uri: the URI to select
1441 * Selects the file to by @uri. If the URI doesn't refer to a
1442 * file in the current folder of @chooser, then the current folder of
1443 * @chooser will be changed to the folder containing @filename.
1445 * Return value: %TRUE if both the folder could be changed and the URI was
1446 * selected successfully, %FALSE otherwise.
1451 gtk_file_chooser_select_uri (GtkFileChooser *chooser,
1457 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1458 g_return_val_if_fail (uri != NULL, FALSE);
1460 file = g_file_new_for_uri (uri);
1461 result = gtk_file_chooser_select_file (chooser, file, NULL);
1462 g_object_unref (file);
1468 * gtk_file_chooser_unselect_uri:
1469 * @chooser: a #GtkFileChooser
1470 * @uri: the URI to unselect
1472 * Unselects the file referred to by @uri. If the file
1473 * is not in the current directory, does not exist, or
1474 * is otherwise not currently selected, does nothing.
1479 gtk_file_chooser_unselect_uri (GtkFileChooser *chooser,
1484 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1485 g_return_if_fail (uri != NULL);
1487 file = g_file_new_for_uri (uri);
1488 gtk_file_chooser_unselect_file (chooser, file);
1489 g_object_unref (file);
1493 * gtk_file_chooser_select_all:
1494 * @chooser: a #GtkFileChooser
1496 * Selects all the files in the current folder of a file chooser.
1501 gtk_file_chooser_select_all (GtkFileChooser *chooser)
1503 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1505 GTK_FILE_CHOOSER_GET_IFACE (chooser)->select_all (chooser);
1509 * gtk_file_chooser_unselect_all:
1510 * @chooser: a #GtkFileChooser
1512 * Unselects all the files in the current folder of a file chooser.
1517 gtk_file_chooser_unselect_all (GtkFileChooser *chooser)
1520 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1522 GTK_FILE_CHOOSER_GET_IFACE (chooser)->unselect_all (chooser);
1526 * gtk_file_chooser_get_uris:
1527 * @chooser: a #GtkFileChooser
1529 * Lists all the selected files and subfolders in the current folder of
1530 * @chooser. The returned names are full absolute URIs.
1532 * Return value: (element-type utf8) (transfer full): a #GSList containing the URIs of all selected
1533 * files and subfolders in the current folder. Free the returned list
1534 * with g_slist_free(), and the filenames with g_free().
1539 gtk_file_chooser_get_uris (GtkFileChooser *chooser)
1541 GSList *files, *result;
1543 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1545 files = gtk_file_chooser_get_files (chooser);
1547 result = files_to_strings (files, g_file_get_uri);
1548 g_slist_foreach (files, (GFunc) g_object_unref, NULL);
1549 g_slist_free (files);
1555 * gtk_file_chooser_set_current_folder_uri:
1556 * @chooser: a #GtkFileChooser
1557 * @uri: the URI for the new current folder
1559 * Sets the current folder for @chooser from an URI.
1560 * The user will be shown the full contents of the current folder,
1561 * plus user interface elements for navigating to other folders.
1563 * Return value: %TRUE if the folder could be changed successfully, %FALSE
1569 gtk_file_chooser_set_current_folder_uri (GtkFileChooser *chooser,
1575 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1576 g_return_val_if_fail (uri != NULL, FALSE);
1578 file = g_file_new_for_uri (uri);
1579 result = gtk_file_chooser_set_current_folder_file (chooser, file, NULL);
1580 g_object_unref (file);
1586 * gtk_file_chooser_get_current_folder_uri:
1587 * @chooser: a #GtkFileChooser
1589 * Gets the current folder of @chooser as an URI.
1590 * See gtk_file_chooser_set_current_folder_uri().
1592 * Note that this is the folder that the file chooser is currently displaying
1593 * (e.g. "file:///home/username/Documents"), which is <emphasis>not the same</emphasis>
1594 * as the currently-selected folder if the chooser is in
1595 * %GTK_FILE_CHOOSER_SELECT_FOLDER mode
1596 * (e.g. "file:///home/username/Documents/selected-folder/". To get the
1597 * currently-selected folder in that mode, use gtk_file_chooser_get_uri() as the
1598 * usual way to get the selection.
1600 * Return value: the URI for the current folder. Free with g_free(). This
1601 * function will also return %NULL if the file chooser was unable to load the
1602 * last folder that was requested from it; for example, as would be for calling
1603 * gtk_file_chooser_set_current_folder_uri() on a nonexistent folder.
1608 gtk_file_chooser_get_current_folder_uri (GtkFileChooser *chooser)
1613 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1615 file = gtk_file_chooser_get_current_folder_file (chooser);
1619 uri = g_file_get_uri (file);
1620 g_object_unref (file);
1626 * gtk_file_chooser_set_current_folder_file:
1627 * @chooser: a #GtkFileChooser
1628 * @file: the #GFile for the new folder
1629 * @error: location to store error, or %NULL.
1631 * Sets the current folder for @chooser from a #GFile.
1632 * Internal function, see gtk_file_chooser_set_current_folder_uri().
1634 * Return value: %TRUE if the folder could be changed successfully, %FALSE
1640 gtk_file_chooser_set_current_folder_file (GtkFileChooser *chooser,
1644 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1645 g_return_val_if_fail (G_IS_FILE (file), FALSE);
1646 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
1648 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->set_current_folder (chooser, file, error);
1652 * gtk_file_chooser_get_current_folder_file:
1653 * @chooser: a #GtkFileChooser
1655 * Gets the current folder of @chooser as #GFile.
1656 * See gtk_file_chooser_get_current_folder_uri().
1658 * Return value: the #GFile for the current folder.
1663 gtk_file_chooser_get_current_folder_file (GtkFileChooser *chooser)
1665 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1667 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_current_folder (chooser);
1671 * gtk_file_chooser_select_file:
1672 * @chooser: a #GtkFileChooser
1673 * @file: the file to select
1674 * @error: location to store error, or %NULL
1676 * Selects the file referred to by @file. An internal function. See
1677 * _gtk_file_chooser_select_uri().
1679 * Return value: %TRUE if both the folder could be changed and the path was
1680 * selected successfully, %FALSE otherwise.
1685 gtk_file_chooser_select_file (GtkFileChooser *chooser,
1689 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1690 g_return_val_if_fail (G_IS_FILE (file), FALSE);
1691 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
1693 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->select_file (chooser, file, error);
1697 * gtk_file_chooser_unselect_file:
1698 * @chooser: a #GtkFileChooser
1701 * Unselects the file referred to by @file. If the file is not in the current
1702 * directory, does not exist, or is otherwise not currently selected, does nothing.
1707 gtk_file_chooser_unselect_file (GtkFileChooser *chooser,
1710 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1711 g_return_if_fail (G_IS_FILE (file));
1713 GTK_FILE_CHOOSER_GET_IFACE (chooser)->unselect_file (chooser, file);
1717 * gtk_file_chooser_get_files:
1718 * @chooser: a #GtkFileChooser
1720 * Lists all the selected files and subfolders in the current folder of @chooser
1721 * as #GFile. An internal function, see gtk_file_chooser_get_uris().
1723 * Return value: (element-type utf8) (transfer full): a #GSList containing a #GFile for each selected
1724 * file and subfolder in the current folder. Free the returned list
1725 * with g_slist_free(), and the files with g_object_unref().
1730 gtk_file_chooser_get_files (GtkFileChooser *chooser)
1732 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1734 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_files (chooser);
1738 * gtk_file_chooser_set_file:
1739 * @chooser: a #GtkFileChooser
1740 * @file: the #GFile to set as current
1741 * @error: location to store the error, or %NULL to ignore errors.
1743 * Sets @file as the current filename for the file chooser, by changing
1744 * to the file's parent folder and actually selecting the file in list. If
1745 * the @chooser is in %GTK_FILE_CHOOSER_ACTION_SAVE mode, the file's base name
1746 * will also appear in the dialog's file name entry.
1748 * If the file name isn't in the current folder of @chooser, then the current
1749 * folder of @chooser will be changed to the folder containing @filename. This
1750 * is equivalent to a sequence of gtk_file_chooser_unselect_all() followed by
1751 * gtk_file_chooser_select_filename().
1753 * Note that the file must exist, or nothing will be done except
1754 * for the directory change.
1756 * If you are implementing a <guimenuitem>File/Save As...</guimenuitem> dialog,
1757 * you should use this function if you already have a file name to which the
1758 * user may save; for example, when the user opens an existing file and then
1759 * does <guimenuitem>File/Save As...</guimenuitem> on it. If you don't have
1760 * a file name already — for example, if the user just created a new
1761 * file and is saving it for the first time, do not call this function.
1762 * Instead, use something similar to this:
1764 * if (document_is_new)
1766 * /* the user just created a new document */
1767 * gtk_file_chooser_set_current_folder_file (chooser, default_file_for_saving);
1768 * gtk_file_chooser_set_current_name (chooser, "Untitled document");
1772 * /* the user edited an existing document */
1773 * gtk_file_chooser_set_file (chooser, existing_file);
1777 * Return value: %TRUE if both the folder could be changed and the file was
1778 * selected successfully, %FALSE otherwise.
1783 gtk_file_chooser_set_file (GtkFileChooser *chooser,
1787 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1788 g_return_val_if_fail (G_IS_FILE (file), FALSE);
1789 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
1791 gtk_file_chooser_unselect_all (chooser);
1792 return gtk_file_chooser_select_file (chooser, file, error);
1796 * gtk_file_chooser_get_file:
1797 * @chooser: a #GtkFileChooser
1799 * Gets the #GFile for the currently selected file in
1800 * the file selector. If multiple files are selected,
1801 * one of the files will be returned at random.
1803 * If the file chooser is in folder mode, this function returns the selected
1806 * Returns: a selected #GFile. You own the returned file; use
1807 * g_object_unref() to release it.
1812 gtk_file_chooser_get_file (GtkFileChooser *chooser)
1815 GFile *result = NULL;
1817 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1819 list = gtk_file_chooser_get_files (chooser);
1822 result = list->data;
1823 list = g_slist_delete_link (list, list);
1825 g_slist_foreach (list, (GFunc) g_object_unref, NULL);
1826 g_slist_free (list);
1833 * _gtk_file_chooser_get_file_system:
1834 * @chooser: a #GtkFileChooser
1836 * Gets the #GtkFileSystem of @chooser; this is an internal
1837 * implementation detail, used for conversion between paths
1838 * and filenames and URIs.
1840 * Return value: the file system for @chooser.
1845 _gtk_file_chooser_get_file_system (GtkFileChooser *chooser)
1847 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1849 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_file_system (chooser);
1855 * gtk_file_chooser_set_preview_widget:
1856 * @chooser: a #GtkFileChooser
1857 * @preview_widget: widget for displaying preview.
1859 * Sets an application-supplied widget to use to display a custom preview
1860 * of the currently selected file. To implement a preview, after setting the
1861 * preview widget, you connect to the #GtkFileChooser::update-preview
1862 * signal, and call gtk_file_chooser_get_preview_filename() or
1863 * gtk_file_chooser_get_preview_uri() on each change. If you can
1864 * display a preview of the new file, update your widget and
1865 * set the preview active using gtk_file_chooser_set_preview_widget_active().
1866 * Otherwise, set the preview inactive.
1868 * When there is no application-supplied preview widget, or the
1869 * application-supplied preview widget is not active, the file chooser
1870 * may display an internally generated preview of the current file or
1871 * it may display no preview at all.
1876 gtk_file_chooser_set_preview_widget (GtkFileChooser *chooser,
1877 GtkWidget *preview_widget)
1879 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1881 g_object_set (chooser, "preview-widget", preview_widget, NULL);
1885 * gtk_file_chooser_get_preview_widget:
1886 * @chooser: a #GtkFileChooser
1888 * Gets the current preview widget; see
1889 * gtk_file_chooser_set_preview_widget().
1891 * Return value: the current preview widget, or %NULL
1896 gtk_file_chooser_get_preview_widget (GtkFileChooser *chooser)
1898 GtkWidget *preview_widget;
1900 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1902 g_object_get (chooser, "preview-widget", &preview_widget, NULL);
1904 /* Horrid hack; g_object_get() refs returned objects but
1905 * that contradicts the memory management conventions
1909 g_object_unref (preview_widget);
1911 return preview_widget;
1915 * gtk_file_chooser_set_preview_widget_active:
1916 * @chooser: a #GtkFileChooser
1917 * @active: whether to display the user-specified preview widget
1919 * Sets whether the preview widget set by
1920 * gtk_file_chooser_set_preview_widget() should be shown for the
1921 * current filename. When @active is set to false, the file chooser
1922 * may display an internally generated preview of the current file
1923 * or it may display no preview at all. See
1924 * gtk_file_chooser_set_preview_widget() for more details.
1929 gtk_file_chooser_set_preview_widget_active (GtkFileChooser *chooser,
1932 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1934 g_object_set (chooser, "preview-widget-active", active, NULL);
1938 * gtk_file_chooser_get_preview_widget_active:
1939 * @chooser: a #GtkFileChooser
1941 * Gets whether the preview widget set by gtk_file_chooser_set_preview_widget()
1942 * should be shown for the current filename. See
1943 * gtk_file_chooser_set_preview_widget_active().
1945 * Return value: %TRUE if the preview widget is active for the current filename.
1950 gtk_file_chooser_get_preview_widget_active (GtkFileChooser *chooser)
1954 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1956 g_object_get (chooser, "preview-widget-active", &active, NULL);
1962 * gtk_file_chooser_set_use_preview_label:
1963 * @chooser: a #GtkFileChooser
1964 * @use_label: whether to display a stock label with the name of the previewed file
1966 * Sets whether the file chooser should display a stock label with the name of
1967 * the file that is being previewed; the default is %TRUE. Applications that
1968 * want to draw the whole preview area themselves should set this to %FALSE and
1969 * display the name themselves in their preview widget.
1971 * See also: gtk_file_chooser_set_preview_widget()
1976 gtk_file_chooser_set_use_preview_label (GtkFileChooser *chooser,
1979 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1981 g_object_set (chooser, "use-preview-label", use_label, NULL);
1985 * gtk_file_chooser_get_use_preview_label:
1986 * @chooser: a #GtkFileChooser
1988 * Gets whether a stock label should be drawn with the name of the previewed
1989 * file. See gtk_file_chooser_set_use_preview_label().
1991 * Return value: %TRUE if the file chooser is set to display a label with the
1992 * name of the previewed file, %FALSE otherwise.
1995 gtk_file_chooser_get_use_preview_label (GtkFileChooser *chooser)
1999 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2001 g_object_get (chooser, "use-preview-label", &use_label, NULL);
2007 * gtk_file_chooser_get_preview_file:
2008 * @chooser: a #GtkFileChooser
2010 * Gets the #GFile that should be previewed in a custom preview
2011 * Internal function, see gtk_file_chooser_get_preview_uri().
2013 * Return value: the #GFile for the file to preview, or %NULL if no file
2014 * is selected. Free with g_object_unref().
2019 gtk_file_chooser_get_preview_file (GtkFileChooser *chooser)
2021 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2023 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_preview_file (chooser);
2027 * _gtk_file_chooser_add_shortcut_folder:
2028 * @chooser: a #GtkFileChooser
2029 * @file: file for the folder to add
2030 * @error: location to store error, or %NULL
2032 * Adds a folder to be displayed with the shortcut folders in a file chooser.
2033 * Internal function, see gtk_file_chooser_add_shortcut_folder().
2035 * Return value: %TRUE if the folder could be added successfully, %FALSE
2041 _gtk_file_chooser_add_shortcut_folder (GtkFileChooser *chooser,
2045 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2046 g_return_val_if_fail (G_IS_FILE (file), FALSE);
2048 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_shortcut_folder (chooser, file, error);
2052 * _gtk_file_chooser_remove_shortcut_folder:
2053 * @chooser: a #GtkFileChooser
2054 * @file: file for the folder to remove
2055 * @error: location to store error, or %NULL
2057 * Removes a folder from the shortcut folders in a file chooser. Internal
2058 * function, see gtk_file_chooser_remove_shortcut_folder().
2060 * Return value: %TRUE if the folder could be removed successfully, %FALSE
2066 _gtk_file_chooser_remove_shortcut_folder (GtkFileChooser *chooser,
2070 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2071 g_return_val_if_fail (G_IS_FILE (file), FALSE);
2073 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_shortcut_folder (chooser, file, error);
2077 * gtk_file_chooser_get_preview_filename:
2078 * @chooser: a #GtkFileChooser
2080 * Gets the filename that should be previewed in a custom preview
2081 * widget. See gtk_file_chooser_set_preview_widget().
2083 * Return value: the filename to preview, or %NULL if no file
2084 * is selected, or if the selected file cannot be represented
2085 * as a local filename. Free with g_free()
2090 gtk_file_chooser_get_preview_filename (GtkFileChooser *chooser)
2093 gchar *result = NULL;
2095 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2097 file = gtk_file_chooser_get_preview_file (chooser);
2100 result = g_file_get_path (file);
2101 g_object_unref (file);
2108 * gtk_file_chooser_get_preview_uri:
2109 * @chooser: a #GtkFileChooser
2111 * Gets the URI that should be previewed in a custom preview
2112 * widget. See gtk_file_chooser_set_preview_widget().
2114 * Return value: the URI for the file to preview, or %NULL if no file is
2115 * selected. Free with g_free().
2120 gtk_file_chooser_get_preview_uri (GtkFileChooser *chooser)
2123 gchar *result = NULL;
2125 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2127 file = gtk_file_chooser_get_preview_file (chooser);
2130 result = g_file_get_uri (file);
2131 g_object_unref (file);
2138 * gtk_file_chooser_set_extra_widget:
2139 * @chooser: a #GtkFileChooser
2140 * @extra_widget: widget for extra options
2142 * Sets an application-supplied widget to provide extra options to the user.
2147 gtk_file_chooser_set_extra_widget (GtkFileChooser *chooser,
2148 GtkWidget *extra_widget)
2150 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
2152 g_object_set (chooser, "extra-widget", extra_widget, NULL);
2156 * gtk_file_chooser_get_extra_widget:
2157 * @chooser: a #GtkFileChooser
2159 * Gets the current preview widget; see
2160 * gtk_file_chooser_set_extra_widget().
2162 * Return value: the current extra widget, or %NULL
2167 gtk_file_chooser_get_extra_widget (GtkFileChooser *chooser)
2169 GtkWidget *extra_widget;
2171 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2173 g_object_get (chooser, "extra-widget", &extra_widget, NULL);
2175 /* Horrid hack; g_object_get() refs returned objects but
2176 * that contradicts the memory management conventions
2180 g_object_unref (extra_widget);
2182 return extra_widget;
2186 * gtk_file_chooser_add_filter:
2187 * @chooser: a #GtkFileChooser
2188 * @filter: a #GtkFileFilter
2190 * Adds @filter to the list of filters that the user can select between.
2191 * When a filter is selected, only files that are passed by that
2192 * filter are displayed.
2194 * Note that the @chooser takes ownership of the filter, so you have to
2195 * ref and sink it if you want to keep a reference.
2200 gtk_file_chooser_add_filter (GtkFileChooser *chooser,
2201 GtkFileFilter *filter)
2203 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
2205 GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_filter (chooser, filter);
2209 * gtk_file_chooser_remove_filter:
2210 * @chooser: a #GtkFileChooser
2211 * @filter: a #GtkFileFilter
2213 * Removes @filter from the list of filters that the user can select between.
2218 gtk_file_chooser_remove_filter (GtkFileChooser *chooser,
2219 GtkFileFilter *filter)
2221 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
2223 GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_filter (chooser, filter);
2227 * gtk_file_chooser_list_filters:
2228 * @chooser: a #GtkFileChooser
2230 * Lists the current set of user-selectable filters; see
2231 * gtk_file_chooser_add_filter(), gtk_file_chooser_remove_filter().
2233 * Return value: (element-type utf8) (transfer container): a #GSList containing the current set of
2234 * user selectable filters. The contents of the list are
2235 * owned by GTK+, but you must free the list itself with
2236 * g_slist_free() when you are done with it.
2241 gtk_file_chooser_list_filters (GtkFileChooser *chooser)
2243 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2245 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->list_filters (chooser);
2249 * gtk_file_chooser_set_filter:
2250 * @chooser: a #GtkFileChooser
2251 * @filter: a #GtkFileFilter
2253 * Sets the current filter; only the files that pass the
2254 * filter will be displayed. If the user-selectable list of filters
2255 * is non-empty, then the filter should be one of the filters
2256 * in that list. Setting the current filter when the list of
2257 * filters is empty is useful if you want to restrict the displayed
2258 * set of files without letting the user change it.
2263 gtk_file_chooser_set_filter (GtkFileChooser *chooser,
2264 GtkFileFilter *filter)
2266 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
2267 g_return_if_fail (GTK_IS_FILE_FILTER (filter));
2269 g_object_set (chooser, "filter", filter, NULL);
2273 * gtk_file_chooser_get_filter:
2274 * @chooser: a #GtkFileChooser
2276 * Gets the current filter; see gtk_file_chooser_set_filter().
2278 * Return value: the current filter, or %NULL
2283 gtk_file_chooser_get_filter (GtkFileChooser *chooser)
2285 GtkFileFilter *filter;
2287 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2289 g_object_get (chooser, "filter", &filter, NULL);
2290 /* Horrid hack; g_object_get() refs returned objects but
2291 * that contradicts the memory management conventions
2295 g_object_unref (filter);
2301 * gtk_file_chooser_add_shortcut_folder:
2302 * @chooser: a #GtkFileChooser
2303 * @folder: filename of the folder to add
2304 * @error: location to store error, or %NULL
2306 * Adds a folder to be displayed with the shortcut folders in a file chooser.
2307 * Note that shortcut folders do not get saved, as they are provided by the
2308 * application. For example, you can use this to add a
2309 * "/usr/share/mydrawprogram/Clipart" folder to the volume list.
2311 * Return value: %TRUE if the folder could be added successfully, %FALSE
2312 * otherwise. In the latter case, the @error will be set as appropriate.
2317 gtk_file_chooser_add_shortcut_folder (GtkFileChooser *chooser,
2324 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2325 g_return_val_if_fail (folder != NULL, FALSE);
2327 file = g_file_new_for_path (folder);
2328 result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_shortcut_folder (chooser, file, error);
2329 g_object_unref (file);
2335 * gtk_file_chooser_remove_shortcut_folder:
2336 * @chooser: a #GtkFileChooser
2337 * @folder: filename of the folder to remove
2338 * @error: location to store error, or %NULL
2340 * Removes a folder from a file chooser's list of shortcut folders.
2342 * Return value: %TRUE if the operation succeeds, %FALSE otherwise.
2343 * In the latter case, the @error will be set as appropriate.
2345 * See also: gtk_file_chooser_add_shortcut_folder()
2350 gtk_file_chooser_remove_shortcut_folder (GtkFileChooser *chooser,
2357 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2358 g_return_val_if_fail (folder != NULL, FALSE);
2360 file = g_file_new_for_path (folder);
2361 result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_shortcut_folder (chooser, file, error);
2362 g_object_unref (file);
2368 * gtk_file_chooser_list_shortcut_folders:
2369 * @chooser: a #GtkFileChooser
2371 * Queries the list of shortcut folders in the file chooser, as set by
2372 * gtk_file_chooser_add_shortcut_folder().
2374 * Return value: (element-type utf8) (transfer full): A list of folder filenames, or %NULL if there are no shortcut
2375 * folders. Free the returned list with g_slist_free(), and the filenames with
2381 gtk_file_chooser_list_shortcut_folders (GtkFileChooser *chooser)
2386 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2388 folders = _gtk_file_chooser_list_shortcut_folder_files (chooser);
2390 result = files_to_strings (folders, g_file_get_path);
2391 g_slist_foreach (folders, (GFunc) g_object_unref, NULL);
2392 g_slist_free (folders);
2398 * gtk_file_chooser_add_shortcut_folder_uri:
2399 * @chooser: a #GtkFileChooser
2400 * @uri: URI of the folder to add
2401 * @error: location to store error, or %NULL
2403 * Adds a folder URI to be displayed with the shortcut folders in a file
2404 * chooser. Note that shortcut folders do not get saved, as they are provided
2405 * by the application. For example, you can use this to add a
2406 * "file:///usr/share/mydrawprogram/Clipart" folder to the volume list.
2408 * Return value: %TRUE if the folder could be added successfully, %FALSE
2409 * otherwise. In the latter case, the @error will be set as appropriate.
2414 gtk_file_chooser_add_shortcut_folder_uri (GtkFileChooser *chooser,
2421 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2422 g_return_val_if_fail (uri != NULL, FALSE);
2424 file = g_file_new_for_uri (uri);
2425 result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_shortcut_folder (chooser, file, error);
2426 g_object_unref (file);
2432 * gtk_file_chooser_remove_shortcut_folder_uri:
2433 * @chooser: a #GtkFileChooser
2434 * @uri: URI of the folder to remove
2435 * @error: location to store error, or %NULL
2437 * Removes a folder URI from a file chooser's list of shortcut folders.
2439 * Return value: %TRUE if the operation succeeds, %FALSE otherwise.
2440 * In the latter case, the @error will be set as appropriate.
2442 * See also: gtk_file_chooser_add_shortcut_folder_uri()
2447 gtk_file_chooser_remove_shortcut_folder_uri (GtkFileChooser *chooser,
2454 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2455 g_return_val_if_fail (uri != NULL, FALSE);
2457 file = g_file_new_for_uri (uri);
2458 result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_shortcut_folder (chooser, file, error);
2459 g_object_unref (file);
2465 * gtk_file_chooser_list_shortcut_folder_uris:
2466 * @chooser: a #GtkFileChooser
2468 * Queries the list of shortcut folders in the file chooser, as set by
2469 * gtk_file_chooser_add_shortcut_folder_uri().
2471 * Return value: (element-type utf8) (transfer full): A list of folder URIs, or %NULL if there are no shortcut
2472 * folders. Free the returned list with g_slist_free(), and the URIs with
2478 gtk_file_chooser_list_shortcut_folder_uris (GtkFileChooser *chooser)
2483 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2485 folders = _gtk_file_chooser_list_shortcut_folder_files (chooser);
2487 result = files_to_strings (folders, g_file_get_uri);
2488 g_slist_foreach (folders, (GFunc) g_object_unref, NULL);
2489 g_slist_free (folders);
2495 _gtk_file_chooser_list_shortcut_folder_files (GtkFileChooser *chooser)
2497 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2499 return GTK_FILE_CHOOSER_GET_IFACE (chooser)->list_shortcut_folders (chooser);
2503 * gtk_file_chooser_set_show_hidden:
2504 * @chooser: a #GtkFileChooser
2505 * @show_hidden: %TRUE if hidden files and folders should be displayed.
2507 * Sets whether hidden files and folders are displayed in the file selector.
2512 gtk_file_chooser_set_show_hidden (GtkFileChooser *chooser,
2513 gboolean show_hidden)
2515 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
2517 g_object_set (chooser, "show-hidden", show_hidden, NULL);
2521 * gtk_file_chooser_get_show_hidden:
2522 * @chooser: a #GtkFileChooser
2524 * Gets whether hidden files and folders are displayed in the file selector.
2525 * See gtk_file_chooser_set_show_hidden().
2527 * Return value: %TRUE if hidden files and folders are displayed.
2532 gtk_file_chooser_get_show_hidden (GtkFileChooser *chooser)
2534 gboolean show_hidden;
2536 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2538 g_object_get (chooser, "show-hidden", &show_hidden, NULL);
2544 * gtk_file_chooser_set_do_overwrite_confirmation:
2545 * @chooser: a #GtkFileChooser
2546 * @do_overwrite_confirmation: whether to confirm overwriting in save mode
2548 * Sets whether a file chooser in %GTK_FILE_CHOOSER_ACTION_SAVE mode will present
2549 * a confirmation dialog if the user types a file name that already exists. This
2550 * is %FALSE by default.
2552 * Regardless of this setting, the @chooser will emit the
2553 * #GtkFileChooser::confirm-overwrite signal when appropriate.
2555 * If all you need is the stock confirmation dialog, set this property to %TRUE.
2556 * You can override the way confirmation is done by actually handling the
2557 * #GtkFileChooser::confirm-overwrite signal; please refer to its documentation
2563 gtk_file_chooser_set_do_overwrite_confirmation (GtkFileChooser *chooser,
2564 gboolean do_overwrite_confirmation)
2566 g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
2568 g_object_set (chooser, "do-overwrite-confirmation", do_overwrite_confirmation, NULL);
2572 * gtk_file_chooser_get_do_overwrite_confirmation:
2573 * @chooser: a #GtkFileChooser
2575 * Queries whether a file chooser is set to confirm for overwriting when the user
2576 * types a file name that already exists.
2578 * Return value: %TRUE if the file chooser will present a confirmation dialog;
2584 gtk_file_chooser_get_do_overwrite_confirmation (GtkFileChooser *chooser)
2586 gboolean do_overwrite_confirmation;
2588 g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2590 g_object_get (chooser, "do-overwrite-confirmation", &do_overwrite_confirmation, NULL);
2592 return do_overwrite_confirmation;
2595 #if defined (G_OS_WIN32) && !defined (_WIN64)
2597 /* DLL ABI stability backward compatibility versions */
2599 #undef gtk_file_chooser_get_filename
2602 gtk_file_chooser_get_filename (GtkFileChooser *chooser)
2604 gchar *utf8_filename = gtk_file_chooser_get_filename_utf8 (chooser);
2605 gchar *retval = g_locale_from_utf8 (utf8_filename, -1, NULL, NULL, NULL);
2607 g_free (utf8_filename);
2612 #undef gtk_file_chooser_set_filename
2615 gtk_file_chooser_set_filename (GtkFileChooser *chooser,
2616 const gchar *filename)
2618 gchar *utf8_filename = g_locale_to_utf8 (filename, -1, NULL, NULL, NULL);
2619 gboolean retval = gtk_file_chooser_set_filename_utf8 (chooser, utf8_filename);
2621 g_free (utf8_filename);
2626 #undef gtk_file_chooser_select_filename
2629 gtk_file_chooser_select_filename (GtkFileChooser *chooser,
2630 const gchar *filename)
2632 gchar *utf8_filename = g_locale_to_utf8 (filename, -1, NULL, NULL, NULL);
2633 gboolean retval = gtk_file_chooser_select_filename_utf8 (chooser, utf8_filename);
2635 g_free (utf8_filename);
2640 #undef gtk_file_chooser_unselect_filename
2643 gtk_file_chooser_unselect_filename (GtkFileChooser *chooser,
2644 const char *filename)
2646 gchar *utf8_filename = g_locale_to_utf8 (filename, -1, NULL, NULL, NULL);
2648 gtk_file_chooser_unselect_filename_utf8 (chooser, utf8_filename);
2649 g_free (utf8_filename);
2652 #undef gtk_file_chooser_get_filenames
2655 gtk_file_chooser_get_filenames (GtkFileChooser *chooser)
2657 GSList *list = gtk_file_chooser_get_filenames_utf8 (chooser);
2658 GSList *rover = list;
2662 gchar *tem = (gchar *) rover->data;
2663 rover->data = g_locale_from_utf8 ((gchar *) rover->data, -1, NULL, NULL, NULL);
2665 rover = rover->next;
2671 #undef gtk_file_chooser_set_current_folder
2674 gtk_file_chooser_set_current_folder (GtkFileChooser *chooser,
2675 const gchar *filename)
2677 gchar *utf8_filename = g_locale_to_utf8 (filename, -1, NULL, NULL, NULL);
2678 gboolean retval = gtk_file_chooser_set_current_folder_utf8 (chooser, utf8_filename);
2680 g_free (utf8_filename);
2685 #undef gtk_file_chooser_get_current_folder
2688 gtk_file_chooser_get_current_folder (GtkFileChooser *chooser)
2690 gchar *utf8_folder = gtk_file_chooser_get_current_folder_utf8 (chooser);
2691 gchar *retval = g_locale_from_utf8 (utf8_folder, -1, NULL, NULL, NULL);
2693 g_free (utf8_folder);
2698 #undef gtk_file_chooser_get_preview_filename
2701 gtk_file_chooser_get_preview_filename (GtkFileChooser *chooser)
2703 char *utf8_filename = gtk_file_chooser_get_preview_filename_utf8 (chooser);
2704 char *retval = g_locale_from_utf8 (utf8_filename, -1, NULL, NULL, NULL);
2706 g_free (utf8_filename);
2711 #undef gtk_file_chooser_add_shortcut_folder
2714 gtk_file_chooser_add_shortcut_folder (GtkFileChooser *chooser,
2718 char *utf8_folder = g_locale_to_utf8 (folder, -1, NULL, NULL, NULL);
2720 gtk_file_chooser_add_shortcut_folder_utf8 (chooser, utf8_folder, error);
2722 g_free (utf8_folder);
2727 #undef gtk_file_chooser_remove_shortcut_folder
2730 gtk_file_chooser_remove_shortcut_folder (GtkFileChooser *chooser,
2734 char *utf8_folder = g_locale_to_utf8 (folder, -1, NULL, NULL, NULL);
2736 gtk_file_chooser_remove_shortcut_folder_utf8 (chooser, utf8_folder, error);
2738 g_free (utf8_folder);
2743 #undef gtk_file_chooser_list_shortcut_folders
2746 gtk_file_chooser_list_shortcut_folders (GtkFileChooser *chooser)
2748 GSList *list = gtk_file_chooser_list_shortcut_folders_utf8 (chooser);
2749 GSList *rover = list;
2753 gchar *tem = (gchar *) rover->data;
2754 rover->data = g_locale_from_utf8 ((gchar *) rover->data, -1, NULL, NULL, NULL);
2756 rover = rover->next;
2764 #define __GTK_FILE_CHOOSER_C__
2765 #include "gtkaliasdef.c"