]> Pileus Git - ~andy/gtk/blob - gtk/gtkfilechooser.c
More documentation fixes
[~andy/gtk] / gtk / gtkfilechooser.c
1 /* GTK - The GIMP Toolkit
2  * gtkfilechooser.c: Abstract interface for file selector GUIs
3  * Copyright (C) 2003, Red Hat, Inc.
4  *
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.
9  *
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.
14  *
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.
19  */
20
21 #include "config.h"
22 #include "gtkfilechooser.h"
23 #include "gtkfilechooserprivate.h"
24 #include "gtkintl.h"
25 #include "gtktypebuiltins.h"
26 #include "gtkprivate.h"
27 #include "gtkmarshalers.h"
28
29
30 /**
31  * SECTION:gtkfilechooser
32  * @Short_description: File chooser interface used by GtkFileChooserWidget and GtkFileChooserDialog
33  * @Title: GtkFileChooser
34  * @See_also: #GtkFileChooserDialog, #GtkFileChooserWidget, #GtkFileChooserButton
35  *
36  * #GtkFileChooser is an interface that can be implemented by file
37  * selection widgets.  In GTK+, the main objects that implement this
38  * interface are #GtkFileChooserWidget, #GtkFileChooserDialog, and
39  * #GtkFileChooserButton.  You do not need to write an object that
40  * implements the #GtkFileChooser interface unless you are trying to
41  * adapt an existing file selector to expose a standard programming
42  * interface.
43  *
44  * #GtkFileChooser allows for shortcuts to various places in the filesystem.
45  * In the default implementation these are displayed in the left pane. It
46  * may be a bit confusing at first that these shortcuts come from various
47  * sources and in various flavours, so lets explain the terminology here:
48  * <variablelist>
49  *    <varlistentry>
50  *       <term>Bookmarks</term>
51  *       <listitem>
52  *          are created by the user, by dragging folders from the
53  *          right pane to the left pane, or by using the "Add". Bookmarks
54  *          can be renamed and deleted by the user.
55  *       </listitem>
56  *    </varlistentry>
57  *    <varlistentry>
58  *       <term>Shortcuts</term>
59  *       <listitem>
60  *          can be provided by the application or by the underlying filesystem
61  *          abstraction (e.g. both the gnome-vfs and the Windows filesystems
62  *          provide "Desktop" shortcuts). Shortcuts cannot be modified by the
63  *          user.
64  *       </listitem>
65  *    </varlistentry>
66  *    <varlistentry>
67  *       <term>Volumes</term>
68  *       <listitem>
69  *          are provided by the underlying filesystem abstraction. They are
70  *          the "roots" of the filesystem.
71  *       </listitem>
72  *    </varlistentry>
73  * </variablelist>
74  *
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
85  * variable.
86  * <note>
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.
95  * </note>
96  * </refsect2>
97  * <refsect2 id="gtkfilechooser-preview">
98  * <title>Adding a Preview Widget</title>
99  * <para>
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.
106  * </para>
107  * <para>
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.
115  * </para>
116  * <example id="example-gtkfilechooser-preview">
117  * <title>Sample Usage</title>
118  * <programlisting>
119  * {
120  *   GtkImage *preview;
121  *
122  *   ...
123  *
124  *   preview = gtk_image_new (<!-- -->);
125  *
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);
129  * }
130  *
131  * static void
132  * update_preview_cb (GtkFileChooser *file_chooser, gpointer data)
133  * {
134  *   GtkWidget *preview;
135  *   char *filename;
136  *   GdkPixbuf *pixbuf;
137  *   gboolean have_preview;
138  *
139  *   preview = GTK_WIDGET (data);
140  *   filename = gtk_file_chooser_get_preview_filename (file_chooser);
141  *
142  *   pixbuf = gdk_pixbuf_new_from_file_at_size (filename, 128, 128, NULL);
143  *   have_preview = (pixbuf != NULL);
144  *   g_free (filename);
145  *
146  *   gtk_image_set_from_pixbuf (GTK_IMAGE (preview), pixbuf);
147  *   if (pixbuf)
148  *     g_object_unref (pixbuf);
149  *
150  *   gtk_file_chooser_set_preview_widget_active (file_chooser, have_preview);
151  * }
152  * </programlisting>
153  * </example>
154  * </refsect2>
155  * <refsect2 id="gtkfilechooser-extra">
156  * <title>Adding Extra Widgets</title>
157  * <para>
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.
164  * </para>
165  * <example id="example-gtkfilechooser-extra">
166  * <title>Sample Usage</title>
167  * <programlisting>
168  *
169  *   GtkWidget *toggle;
170  *
171  *   ...
172  *
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);
176  * }
177  * </programlisting>
178  * </example>
179  * <note>
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.
184  * </note>
185  * </refsect2>
186  * <refsect2 id="gtkfilechooser-key-bindings">
187  * <title>Key Bindings</title>
188  * <para>
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.
195  * </para>
196  * <example id="gtkfilechooser-key-binding-example">
197  * <title>GtkFileChooser key binding example</title>
198  * <para>
199  * The default keys that activate the key-binding signals in
200  * <classname>GtkFileChooserDefaultClass</classname> are as
201  * follows:
202  * </para>
203  *      <informaltable>
204  *        <tgroup cols="2">
205  *          <tbody>
206  *            <row>
207  *              <entry>Signal name</entry>
208  *              <entry>Default key combinations</entry>
209  *            </row>
210  *            <row>
211  *              <entry>location-popup</entry>
212  *              <entry>
213  *                <keycombo><keycap>Control</keycap><keycap>L</keycap></keycombo> (empty path);
214  *                <keycap>/</keycap> (path of "/")
215  *                <footnote>
216  *                    Both the individual <keycap>/</keycap> key and the
217  *                    numeric keypad's "divide" key are supported.
218  *                </footnote>;
219  *                <keycap>~</keycap> (path of "~")
220  *              </entry>
221  *            </row>
222  *            <row>
223  *              <entry>up-folder</entry>
224  *              <entry>
225  *                <keycombo><keycap>Alt</keycap><keycap>Up</keycap></keycombo>
226  *                <footnote>
227  *                    Both the individual Up key and the numeric
228  *                    keypad's Up key are supported.
229  *                </footnote>
230  *                ;
231  *                <keycap>Backspace</keycap>
232  *              </entry>
233  *            </row>
234  *            <row>
235  *              <entry>down-folder</entry>
236  *              <entry><keycombo><keycap>Alt</keycap><keycap>Down</keycap></keycombo></entry>
237  *            </row>
238  *            <row>
239  *              <entry>home-folder</entry>
240  *              <entry><keycombo><keycap>Alt</keycap><keycap>Home</keycap></keycombo></entry>
241  *            </row>
242  *            <row>
243  *              <entry>desktop-folder</entry>
244  *              <entry><keycombo><keycap>Alt</keycap><keycap>D</keycap></keycombo></entry>
245  *            </row>
246  *            <row>
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>
249  *            </row>
250  *          </tbody>
251  *        </tgroup>
252  *      </informaltable>
253  * <para>
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-3.0</filename> file:
258  * </para>
259  * <programlisting>
260  * binding "my-own-gtkfilechooser-bindings" {
261  *      bind "&lt;Alt&gt;&lt;Shift&gt;Up" {
262  *              "up-folder" ()
263  *      }
264  *      bind "&lt;Alt&gt;&lt;Shift&gt;Down" {
265  *              "down-folder" ()
266  *      }
267  *      bind "&lt;Alt&gt;&lt;Shift&gt;Home" {
268  *              "home-folder" ()
269  *      }
270  * }
271  *
272  * class "GtkFileChooserDefault" binding "my-own-gtkfilechooser-bindings"
273  * </programlisting>
274  * </example>
275  * <refsect3 id="GtkFileChooserDefault-location-popup">
276  * <title>The &quot;GtkFileChooserDefault::location-popup&quot; signal</title>
277  * <programlisting>
278  *    void user_function (GtkFileChooserDefault *chooser,
279  *                        const char            *path,
280  * <link linkend="gpointer">gpointer</link>      user_data);
281  * </programlisting>
282  * <para>
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.
296  * </para>
297  *      <variablelist role="params">
298  *        <varlistentry>
299  *          <term><parameter>chooser</parameter>&nbsp;:</term>
300  *          <listitem>
301  *            <simpara>
302  *              the object which received the signal.
303  *            </simpara>
304  *          </listitem>
305  *        </varlistentry>
306  *        <varlistentry>
307  *          <term><parameter>path</parameter>&nbsp;:</term>
308  *          <listitem>
309  *            <simpara>
310  *              default contents for the text entry for the file name
311  *            </simpara>
312  *          </listitem>
313  *        </varlistentry>
314  *        <varlistentry>
315  *          <term><parameter>user_data</parameter>&nbsp;:</term>
316  *          <listitem>
317  *            <simpara>
318  *              user data set when the signal handler was connected.
319  *            </simpara>
320  *          </listitem>
321  *        </varlistentry>
322  *      </variablelist>
323  * <note>
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-3.0</filename>:
333  *    <programlisting>
334  *    binding "misc-shortcut" {
335  *       bind "&lt;Alt&gt;M" {
336  *          "location-popup" ("/home/username/misc")
337  *       }
338  *    }
339  *
340  *    class "GtkFileChooserDefault" binding "misc-shortcut"
341  *    </programlisting>
342  * </note>
343  * </refsect3>
344  * <refsect3 id="GtkFileChooserDefault-up-folder">
345  * <title>The &quot;GtkFileChooserDefault::up-folder&quot; signal</title>
346  * <programlisting>
347  *           void user_function (GtkFileChooserDefault *chooser,
348  *                               <link linkend="gpointer">gpointer</link> user_data);
349  * </programlisting>
350  * <para>
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).
356  * </para>
357  *      <variablelist role="params">
358  *        <varlistentry>
359  *          <term><parameter>chooser</parameter>&nbsp;:</term>
360  *          <listitem>
361  *            <simpara>
362  *              the object which received the signal.
363  *            </simpara>
364  *          </listitem>
365  *        </varlistentry>
366  *        <varlistentry>
367  *          <term><parameter>user_data</parameter>&nbsp;:</term>
368  *          <listitem>
369  *            <simpara>
370  *              user data set when the signal handler was connected.
371  *            </simpara>
372  *          </listitem>
373  *        </varlistentry>
374  *      </variablelist>
375  * </refsect3>
376  * <refsect3 id="GtkFileChooserDefault-down-folder">
377  * <title>The &quot;GtkFileChooserDefault::down-folder&quot; signal</title>
378  * <programlisting>
379  *           void user_function (GtkFileChooserDefault *chooser,
380  *                               <link linkend="gpointer">gpointer</link> user_data);
381  * </programlisting>
382  * <para>
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).
392  * </para>
393  *      <variablelist role="params">
394  *        <varlistentry>
395  *          <term><parameter>chooser</parameter>&nbsp;:</term>
396  *          <listitem>
397  *            <simpara>
398  *              the object which received the signal.
399  *            </simpara>
400  *          </listitem>
401  *        </varlistentry>
402  *        <varlistentry>
403  *          <term><parameter>user_data</parameter>&nbsp;:</term>
404  *          <listitem>
405  *            <simpara>
406  *              user data set when the signal handler was connected.
407  *            </simpara>
408  *          </listitem>
409  *        </varlistentry>
410  *      </variablelist>
411  * </refsect3>
412  * <refsect3 id="GtkFileChooserDefault-home-folder">
413  * <title>The &quot;GtkFileChooserDefault::home-folder&quot; signal</title>
414  * <programlisting>
415  *           void user_function (GtkFileChooserDefault *chooser,
416  *                               <link linkend="gpointer">gpointer</link> user_data);
417  * </programlisting>
418  * <para>
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).
423  * </para>
424  *      <variablelist role="params">
425  *        <varlistentry>
426  *          <term><parameter>chooser</parameter>&nbsp;:</term>
427  *          <listitem>
428  *            <simpara>
429  *              the object which received the signal.
430  *            </simpara>
431  *          </listitem>
432  *        </varlistentry>
433  *        <varlistentry>
434  *          <term><parameter>user_data</parameter>&nbsp;:</term>
435  *          <listitem>
436  *            <simpara>
437  *              user data set when the signal handler was connected.
438  *            </simpara>
439  *          </listitem>
440  *        </varlistentry>
441  *      </variablelist>
442  * </refsect3>
443  * <refsect3 id="GtkFileChooserDefault-desktop-folder">
444  * <title>The &quot;GtkFileChooserDefault::desktop-folder&quot; signal</title>
445  * <programlisting>
446  *           void user_function (GtkFileChooserDefault *chooser,
447  *                               <link linkend="gpointer">gpointer</link> user_data);
448  * </programlisting>
449  * <para>
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>.
453  * </para>
454  *      <variablelist role="params">
455  *        <varlistentry>
456  *          <term><parameter>chooser</parameter>&nbsp;:</term>
457  *          <listitem>
458  *            <simpara>
459  *              the object which received the signal.
460  *            </simpara>
461  *          </listitem>
462  *        </varlistentry>
463  *        <varlistentry>
464  *          <term><parameter>user_data</parameter>&nbsp;:</term>
465  *          <listitem>
466  *            <simpara>
467  *              user data set when the signal handler was connected.
468  *            </simpara>
469  *          </listitem>
470  *        </varlistentry>
471  *      </variablelist>
472  * </refsect3>
473  * <refsect3 id="GtkFileChooserDefault-quick-bookmark">
474  * <title>The &quot;GtkFileChooserDefault::quick-bookmark&quot; signal</title>
475  * <programlisting>
476  *           void user_function (GtkFileChooserDefault *chooser,
477  *                               gint bookmark_index,
478  *                               <link linkend="gpointer">gpointer</link> user_data);
479  * </programlisting>
480  * <para>
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>,
487  * etc. until
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
492  * successively;
493  * <keycombo><keycap>Alt</keycap><keycap>0</keycap></keycombo> is
494  * defined to switch to the bookmark at index 10.
495  * </para>
496  *      <variablelist role="params">
497  *        <varlistentry>
498  *          <term><parameter>chooser</parameter>&nbsp;:</term>
499  *          <listitem>
500  *            <simpara>
501  *              the object which received the signal.
502  *            </simpara>
503  *          </listitem>
504  *        </varlistentry>
505  *        <varlistentry>
506  *          <term><parameter>bookmark_indes</parameter>&nbsp;:</term>
507  *          <listitem>
508  *            <simpara>
509  *              index of the bookmark to switch to; the indices start at 0.
510  *            </simpara>
511  *          </listitem>
512  *        </varlistentry>
513  *        <varlistentry>
514  *          <term><parameter>user_data</parameter>&nbsp;:</term>
515  *          <listitem>
516  *            <simpara>
517  *              user data set when the signal handler was connected.
518  *            </simpara>
519  *          </listitem>
520  *        </varlistentry>
521  *      </variablelist>
522  * </refsect3>
523  * </refsect2>
524  */
525
526
527 typedef GtkFileChooserIface GtkFileChooserInterface;
528 G_DEFINE_INTERFACE (GtkFileChooser, gtk_file_chooser, GTK_TYPE_WIDGET);
529
530 static gboolean
531 confirm_overwrite_accumulator (GSignalInvocationHint *ihint,
532                                GValue                *return_accu,
533                                const GValue          *handler_return,
534                                gpointer               dummy)
535 {
536   gboolean continue_emission;
537   GtkFileChooserConfirmation conf;
538
539   conf = g_value_get_enum (handler_return);
540   g_value_set_enum (return_accu, conf);
541   continue_emission = (conf == GTK_FILE_CHOOSER_CONFIRMATION_CONFIRM);
542
543   return continue_emission;
544 }
545
546 static void
547 gtk_file_chooser_default_init (GtkFileChooserInterface *iface)
548 {
549   GType iface_type = G_TYPE_FROM_INTERFACE (iface);
550
551   /**
552    * GtkFileChooser::current-folder-changed
553    * @chooser: the object which received the signal.
554    *
555    * This signal is emitted when the current folder in a #GtkFileChooser
556    * changes.  This can happen due to the user performing some action that
557    * changes folders, such as selecting a bookmark or visiting a folder on the
558    * file list.  It can also happen as a result of calling a function to
559    * explicitly change the current folder in a file chooser.
560    *
561    * Normally you do not need to connect to this signal, unless you need to keep
562    * track of which folder a file chooser is showing.
563    *
564    * See also:  gtk_file_chooser_set_current_folder(),
565    * gtk_file_chooser_get_current_folder(),
566    * gtk_file_chooser_set_current_folder_uri(),
567    * gtk_file_chooser_get_current_folder_uri().
568    */
569   g_signal_new (I_("current-folder-changed"),
570                 iface_type,
571                 G_SIGNAL_RUN_LAST,
572                 G_STRUCT_OFFSET (GtkFileChooserIface, current_folder_changed),
573                 NULL, NULL,
574                 g_cclosure_marshal_VOID__VOID,
575                 G_TYPE_NONE, 0);
576
577   /**
578    * GtkFileChooser::selection-changed
579    * @chooser: the object which received the signal.
580    *
581    * This signal is emitted when there is a change in the set of selected files
582    * in a #GtkFileChooser.  This can happen when the user modifies the selection
583    * with the mouse or the keyboard, or when explicitly calling functions to
584    * change the selection.
585    *
586    * Normally you do not need to connect to this signal, as it is easier to wait
587    * for the file chooser to finish running, and then to get the list of
588    * selected files using the functions mentioned below.
589    *
590    * See also: gtk_file_chooser_select_filename(),
591    * gtk_file_chooser_unselect_filename(), gtk_file_chooser_get_filename(),
592    * gtk_file_chooser_get_filenames(), gtk_file_chooser_select_uri(),
593    * gtk_file_chooser_unselect_uri(), gtk_file_chooser_get_uri(),
594    * gtk_file_chooser_get_uris().
595    */
596   g_signal_new (I_("selection-changed"),
597                 iface_type,
598                 G_SIGNAL_RUN_LAST,
599                 G_STRUCT_OFFSET (GtkFileChooserIface, selection_changed),
600                 NULL, NULL,
601                 g_cclosure_marshal_VOID__VOID,
602                 G_TYPE_NONE, 0);
603
604   /**
605    * GtkFileChooser::update-preview
606    * @chooser: the object which received the signal.
607    *
608    * This signal is emitted when the preview in a file chooser should be
609    * regenerated.  For example, this can happen when the currently selected file
610    * changes.  You should use this signal if you want your file chooser to have
611    * a preview widget.
612    *
613    * Once you have installed a preview widget with
614    * gtk_file_chooser_set_preview_widget(), you should update it when this
615    * signal is emitted.  You can use the functions
616    * gtk_file_chooser_get_preview_filename() or
617    * gtk_file_chooser_get_preview_uri() to get the name of the file to preview.
618    * Your widget may not be able to preview all kinds of files; your callback
619    * must call gtk_file_chooser_set_preview_widget_active() to inform the file
620    * chooser about whether the preview was generated successfully or not.
621    *
622    * Please see the example code in <xref linkend="gtkfilechooser-preview"/>.
623    *
624    * See also: gtk_file_chooser_set_preview_widget(),
625    * gtk_file_chooser_set_preview_widget_active(),
626    * gtk_file_chooser_set_use_preview_label(),
627    * gtk_file_chooser_get_preview_filename(),
628    * gtk_file_chooser_get_preview_uri().
629    */
630   g_signal_new (I_("update-preview"),
631                 iface_type,
632                 G_SIGNAL_RUN_LAST,
633                 G_STRUCT_OFFSET (GtkFileChooserIface, update_preview),
634                 NULL, NULL,
635                 g_cclosure_marshal_VOID__VOID,
636                 G_TYPE_NONE, 0);
637
638   /**
639    * GtkFileChooser::file-activated
640    * @chooser: the object which received the signal.
641    *
642    * This signal is emitted when the user "activates" a file in the file
643    * chooser.  This can happen by double-clicking on a file in the file list, or
644    * by pressing <keycap>Enter</keycap>.
645    *
646    * Normally you do not need to connect to this signal.  It is used internally
647    * by #GtkFileChooserDialog to know when to activate the default button in the
648    * dialog.
649    *
650    * See also: gtk_file_chooser_get_filename(),
651    * gtk_file_chooser_get_filenames(), gtk_file_chooser_get_uri(),
652    * gtk_file_chooser_get_uris().
653    */
654   g_signal_new (I_("file-activated"),
655                 iface_type,
656                 G_SIGNAL_RUN_LAST,
657                 G_STRUCT_OFFSET (GtkFileChooserIface, file_activated),
658                 NULL, NULL,
659                 g_cclosure_marshal_VOID__VOID,
660                 G_TYPE_NONE, 0);
661
662   /**
663    * GtkFileChooser::confirm-overwrite:
664    * @chooser: the object which received the signal.
665    *
666    * This signal gets emitted whenever it is appropriate to present a
667    * confirmation dialog when the user has selected a file name that
668    * already exists.  The signal only gets emitted when the file
669    * chooser is in %GTK_FILE_CHOOSER_ACTION_SAVE mode.
670    *
671    * Most applications just need to turn on the
672    * #GtkFileChooser:do-overwrite-confirmation property (or call the
673    * gtk_file_chooser_set_do_overwrite_confirmation() function), and
674    * they will automatically get a stock confirmation dialog.
675    * Applications which need to customize this behavior should do
676    * that, and also connect to the #GtkFileChooser::confirm-overwrite
677    * signal.
678    *
679    * A signal handler for this signal must return a
680    * #GtkFileChooserConfirmation value, which indicates the action to
681    * take.  If the handler determines that the user wants to select a
682    * different filename, it should return
683    * %GTK_FILE_CHOOSER_CONFIRMATION_SELECT_AGAIN.  If it determines
684    * that the user is satisfied with his choice of file name, it
685    * should return %GTK_FILE_CHOOSER_CONFIRMATION_ACCEPT_FILENAME.
686    * On the other hand, if it determines that the stock confirmation
687    * dialog should be used, it should return
688    * %GTK_FILE_CHOOSER_CONFIRMATION_CONFIRM. The following example
689    * illustrates this.
690    * <example id="gtkfilechooser-confirmation">
691    * <title>Custom confirmation</title>
692    * <programlisting>
693    * static GtkFileChooserConfirmation
694    * confirm_overwrite_callback (GtkFileChooser *chooser, gpointer data)
695    * {
696    *   char *uri;
697    *
698    *   uri = gtk_file_chooser_get_uri (chooser);
699    *
700    *   if (is_uri_read_only (uri))
701    *     {
702    *       if (user_wants_to_replace_read_only_file (uri))
703    *         return GTK_FILE_CHOOSER_CONFIRMATION_ACCEPT_FILENAME;
704    *       else
705    *         return GTK_FILE_CHOOSER_CONFIRMATION_SELECT_AGAIN;
706    *     } else
707    *       return GTK_FILE_CHOOSER_CONFIRMATION_CONFIRM; // fall back to the default dialog
708    * }
709    *
710    * ...
711    *
712    * chooser = gtk_file_chooser_dialog_new (...);
713    *
714    * gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), TRUE);
715    * g_signal_connect (chooser, "confirm-overwrite",
716    *                   G_CALLBACK (confirm_overwrite_callback), NULL);
717    *
718    * if (gtk_dialog_run (chooser) == GTK_RESPONSE_ACCEPT)
719    *         save_to_file (gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (chooser));
720    *
721    * gtk_widget_destroy (chooser);
722    * </programlisting>
723    * </example>
724    *
725    * Returns: a #GtkFileChooserConfirmation value that indicates which
726    *  action to take after emitting the signal.
727    *
728    * Since: 2.8
729    */
730   g_signal_new (I_("confirm-overwrite"),
731                 iface_type,
732                 G_SIGNAL_RUN_LAST,
733                 G_STRUCT_OFFSET (GtkFileChooserIface, confirm_overwrite),
734                 confirm_overwrite_accumulator, NULL,
735                 _gtk_marshal_ENUM__VOID,
736                 GTK_TYPE_FILE_CHOOSER_CONFIRMATION, 0);
737   
738   g_object_interface_install_property (iface,
739                                        g_param_spec_enum ("action",
740                                                           P_("Action"),
741                                                           P_("The type of operation that the file selector is performing"),
742                                                           GTK_TYPE_FILE_CHOOSER_ACTION,
743                                                           GTK_FILE_CHOOSER_ACTION_OPEN,
744                                                           GTK_PARAM_READWRITE));
745   g_object_interface_install_property (iface,
746                                        g_param_spec_object ("filter",
747                                                             P_("Filter"),
748                                                             P_("The current filter for selecting which files are displayed"),
749                                                             GTK_TYPE_FILE_FILTER,
750                                                             GTK_PARAM_READWRITE));
751   g_object_interface_install_property (iface,
752                                        g_param_spec_boolean ("local-only",
753                                                              P_("Local Only"),
754                                                              P_("Whether the selected file(s) should be limited to local file: URLs"),
755                                                              TRUE,
756                                                              GTK_PARAM_READWRITE));
757   g_object_interface_install_property (iface,
758                                        g_param_spec_object ("preview-widget",
759                                                             P_("Preview widget"),
760                                                             P_("Application supplied widget for custom previews."),
761                                                             GTK_TYPE_WIDGET,
762                                                             GTK_PARAM_READWRITE));
763   g_object_interface_install_property (iface,
764                                        g_param_spec_boolean ("preview-widget-active",
765                                                              P_("Preview Widget Active"),
766                                                              P_("Whether the application supplied widget for custom previews should be shown."),
767                                                              TRUE,
768                                                              GTK_PARAM_READWRITE));
769   g_object_interface_install_property (iface,
770                                        g_param_spec_boolean ("use-preview-label",
771                                                              P_("Use Preview Label"),
772                                                              P_("Whether to display a stock label with the name of the previewed file."),
773                                                              TRUE,
774                                                              GTK_PARAM_READWRITE));
775   g_object_interface_install_property (iface,
776                                        g_param_spec_object ("extra-widget",
777                                                             P_("Extra widget"),
778                                                             P_("Application supplied widget for extra options."),
779                                                             GTK_TYPE_WIDGET,
780                                                             GTK_PARAM_READWRITE));
781   g_object_interface_install_property (iface,
782                                        g_param_spec_boolean ("select-multiple",
783                                                              P_("Select Multiple"),
784                                                              P_("Whether to allow multiple files to be selected"),
785                                                              FALSE,
786                                                              GTK_PARAM_READWRITE));
787
788   g_object_interface_install_property (iface,
789                                        g_param_spec_boolean ("show-hidden",
790                                                              P_("Show Hidden"),
791                                                              P_("Whether the hidden files and folders should be displayed"),
792                                                              FALSE,
793                                                              GTK_PARAM_READWRITE));
794
795   /**
796    * GtkFileChooser:do-overwrite-confirmation:
797    * 
798    * Whether a file chooser in %GTK_FILE_CHOOSER_ACTION_SAVE mode
799    * will present an overwrite confirmation dialog if the user
800    * selects a file name that already exists.
801    *
802    * Since: 2.8
803    */
804   g_object_interface_install_property (iface,
805                                        g_param_spec_boolean ("do-overwrite-confirmation",
806                                                              P_("Do overwrite confirmation"),
807                                                              P_("Whether a file chooser in save mode "
808                                                                 "will present an overwrite confirmation dialog "
809                                                                 "if necessary."),
810                                                              FALSE,
811                                                              GTK_PARAM_READWRITE));
812
813   /**
814    * GtkFileChooser:create-folders:
815    * 
816    * Whether a file chooser not in %GTK_FILE_CHOOSER_ACTION_OPEN mode
817    * will offer the user to create new folders.
818    *
819    * Since: 2.18
820    */
821   g_object_interface_install_property (iface,
822                                        g_param_spec_boolean ("create-folders",
823                                                              P_("Allow folder creation"),
824                                                              P_("Whether a file chooser not in open mode "
825                                                                 "will offer the user to create new folders."),
826                                                              TRUE,
827                                                              GTK_PARAM_READWRITE));
828 }
829
830 /**
831  * gtk_file_chooser_error_quark:
832  *
833  * Registers an error quark for #GtkFileChooser if necessary.
834  * 
835  * Return value: The error quark used for #GtkFileChooser errors.
836  *
837  * Since: 2.4
838  **/
839 GQuark
840 gtk_file_chooser_error_quark (void)
841 {
842   return g_quark_from_static_string ("gtk-file-chooser-error-quark");
843 }
844
845 /**
846  * gtk_file_chooser_set_action:
847  * @chooser: a #GtkFileChooser
848  * @action: the action that the file selector is performing
849  * 
850  * Sets the type of operation that the chooser is performing; the
851  * user interface is adapted to suit the selected action. For example,
852  * an option to create a new folder might be shown if the action is
853  * %GTK_FILE_CHOOSER_ACTION_SAVE but not if the action is
854  * %GTK_FILE_CHOOSER_ACTION_OPEN.
855  *
856  * Since: 2.4
857  **/
858 void
859 gtk_file_chooser_set_action (GtkFileChooser       *chooser,
860                              GtkFileChooserAction  action)
861 {
862   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
863
864   g_object_set (chooser, "action", action, NULL);
865 }
866
867 /**
868  * gtk_file_chooser_get_action:
869  * @chooser: a #GtkFileChooser
870  * 
871  * Gets the type of operation that the file chooser is performing; see
872  * gtk_file_chooser_set_action().
873  * 
874  * Return value: the action that the file selector is performing
875  *
876  * Since: 2.4
877  **/
878 GtkFileChooserAction
879 gtk_file_chooser_get_action (GtkFileChooser *chooser)
880 {
881   GtkFileChooserAction action;
882   
883   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
884
885   g_object_get (chooser, "action", &action, NULL);
886
887   return action;
888 }
889
890 /**
891  * gtk_file_chooser_set_local_only:
892  * @chooser: a #GtkFileChooser
893  * @local_only: %TRUE if only local files can be selected
894  * 
895  * Sets whether only local files can be selected in the
896  * file selector. If @local_only is %TRUE (the default),
897  * then the selected file are files are guaranteed to be
898  * accessible through the operating systems native file
899  * file system and therefore the application only
900  * needs to worry about the filename functions in
901  * #GtkFileChooser, like gtk_file_chooser_get_filename(),
902  * rather than the URI functions like
903  * gtk_file_chooser_get_uri(),
904  *
905  * Since: 2.4
906  **/
907 void
908 gtk_file_chooser_set_local_only (GtkFileChooser *chooser,
909                                  gboolean        local_only)
910 {
911   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
912
913   g_object_set (chooser, "local-only", local_only, NULL);
914 }
915
916 /**
917  * gtk_file_chooser_get_local_only:
918  * @chooser: a #GtkFileChooser
919  * 
920  * Gets whether only local files can be selected in the
921  * file selector. See gtk_file_chooser_set_local_only()
922  * 
923  * Return value: %TRUE if only local files can be selected.
924  *
925  * Since: 2.4
926  **/
927 gboolean
928 gtk_file_chooser_get_local_only (GtkFileChooser *chooser)
929 {
930   gboolean local_only;
931   
932   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
933
934   g_object_get (chooser, "local-only", &local_only, NULL);
935
936   return local_only;
937 }
938
939 /**
940  * gtk_file_chooser_set_select_multiple:
941  * @chooser: a #GtkFileChooser
942  * @select_multiple: %TRUE if multiple files can be selected.
943  * 
944  * Sets whether multiple files can be selected in the file selector.  This is
945  * only relevant if the action is set to be %GTK_FILE_CHOOSER_ACTION_OPEN or
946  * %GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER.
947  *
948  * Since: 2.4
949  **/
950 void
951 gtk_file_chooser_set_select_multiple (GtkFileChooser *chooser,
952                                       gboolean        select_multiple)
953 {
954   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
955
956   g_object_set (chooser, "select-multiple", select_multiple, NULL);
957 }
958
959 /**
960  * gtk_file_chooser_get_select_multiple:
961  * @chooser: a #GtkFileChooser
962  * 
963  * Gets whether multiple files can be selected in the file
964  * selector. See gtk_file_chooser_set_select_multiple().
965  * 
966  * Return value: %TRUE if multiple files can be selected.
967  *
968  * Since: 2.4
969  **/
970 gboolean
971 gtk_file_chooser_get_select_multiple (GtkFileChooser *chooser)
972 {
973   gboolean select_multiple;
974   
975   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
976
977   g_object_get (chooser, "select-multiple", &select_multiple, NULL);
978
979   return select_multiple;
980 }
981
982 /**
983  * gtk_file_chooser_set_create_folders:
984  * @chooser: a #GtkFileChooser
985  * @create_folders: %TRUE if the New Folder button should be displayed
986  * 
987  * Sets whether file choser will offer to create new folders.
988  * This is only relevant if the action is not set to be 
989  * %GTK_FILE_CHOOSER_ACTION_OPEN.
990  *
991  * Since: 2.18
992  **/
993 void
994 gtk_file_chooser_set_create_folders (GtkFileChooser *chooser,
995                                      gboolean        create_folders)
996 {
997   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
998
999   g_object_set (chooser, "create-folders", create_folders, NULL);
1000 }
1001
1002 /**
1003  * gtk_file_chooser_get_create_folders:
1004  * @chooser: a #GtkFileChooser
1005  * 
1006  * Gets whether file choser will offer to create new folders.
1007  * See gtk_file_chooser_set_create_folders().
1008  * 
1009  * Return value: %TRUE if the New Folder button should be displayed.
1010  *
1011  * Since: 2.18
1012  **/
1013 gboolean
1014 gtk_file_chooser_get_create_folders (GtkFileChooser *chooser)
1015 {
1016   gboolean create_folders;
1017   
1018   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1019
1020   g_object_get (chooser, "create-folders", &create_folders, NULL);
1021
1022   return create_folders;
1023 }
1024
1025 /**
1026  * gtk_file_chooser_get_filename:
1027  * @chooser: a #GtkFileChooser
1028  * 
1029  * Gets the filename for the currently selected file in
1030  * the file selector. If multiple files are selected,
1031  * one of the filenames will be returned at random.
1032  *
1033  * If the file chooser is in folder mode, this function returns the selected
1034  * folder.
1035  * 
1036  * Return value: The currently selected filename, or %NULL
1037  *  if no file is selected, or the selected file can't
1038  *  be represented with a local filename. Free with g_free().
1039  *
1040  * Since: 2.4
1041  **/
1042 gchar *
1043 gtk_file_chooser_get_filename (GtkFileChooser *chooser)
1044 {
1045   GFile *file;
1046   gchar *result = NULL;
1047
1048   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1049
1050   file = gtk_file_chooser_get_file (chooser);
1051
1052   if (file)
1053     {
1054       result = g_file_get_path (file);
1055       g_object_unref (file);
1056     }
1057
1058   return result;
1059 }
1060
1061 /**
1062  * gtk_file_chooser_set_filename:
1063  * @chooser: a #GtkFileChooser
1064  * @filename: the filename to set as current
1065  * 
1066  * Sets @filename as the current filename for the file chooser, by changing
1067  * to the file's parent folder and actually selecting the file in list.  If
1068  * the @chooser is in %GTK_FILE_CHOOSER_ACTION_SAVE mode, the file's base name
1069  * will also appear in the dialog's file name entry.
1070  *
1071  * If the file name isn't in the current folder of @chooser, then the current
1072  * folder of @chooser will be changed to the folder containing @filename. This
1073  * is equivalent to a sequence of gtk_file_chooser_unselect_all() followed by
1074  * gtk_file_chooser_select_filename().
1075  *
1076  * Note that the file must exist, or nothing will be done except
1077  * for the directory change.
1078  *
1079  * If you are implementing a <guimenuitem>File/Save As...</guimenuitem> dialog,
1080  * you should use this function if you already have a file name to which the 
1081  * user may save; for example, when the user opens an existing file and then 
1082  * does <guimenuitem>File/Save As...</guimenuitem> on it.  If you don't have 
1083  * a file name already &mdash; for example, if the user just created a new 
1084  * file and is saving it for the first time, do not call this function.  
1085  * Instead, use something similar to this:
1086  * |[
1087  * if (document_is_new)
1088  *   {
1089  *     /&ast; the user just created a new document &ast;/
1090  *     gtk_file_chooser_set_current_folder (chooser, default_folder_for_saving);
1091  *     gtk_file_chooser_set_current_name (chooser, "Untitled document");
1092  *   }
1093  * else
1094  *   {
1095  *     /&ast; the user edited an existing document &ast;/ 
1096  *     gtk_file_chooser_set_filename (chooser, existing_filename);
1097  *   }
1098  * ]|
1099  * 
1100  * Return value: %TRUE if both the folder could be changed and the file was
1101  * selected successfully, %FALSE otherwise.
1102  *
1103  * Since: 2.4
1104  **/
1105 gboolean
1106 gtk_file_chooser_set_filename (GtkFileChooser *chooser,
1107                                const gchar    *filename)
1108 {
1109   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1110
1111   gtk_file_chooser_unselect_all (chooser);
1112   return gtk_file_chooser_select_filename (chooser, filename);
1113 }
1114
1115 /**
1116  * gtk_file_chooser_select_filename:
1117  * @chooser: a #GtkFileChooser
1118  * @filename: the filename to select
1119  * 
1120  * Selects a filename. If the file name isn't in the current
1121  * folder of @chooser, then the current folder of @chooser will
1122  * be changed to the folder containing @filename.
1123  *
1124  * Return value: %TRUE if both the folder could be changed and the file was
1125  * selected successfully, %FALSE otherwise.
1126  *
1127  * Since: 2.4
1128  **/
1129 gboolean
1130 gtk_file_chooser_select_filename (GtkFileChooser *chooser,
1131                                   const gchar    *filename)
1132 {
1133   GFile *file;
1134   gboolean result;
1135   
1136   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1137   g_return_val_if_fail (filename != NULL, FALSE);
1138
1139   file = g_file_new_for_path (filename);
1140   result = gtk_file_chooser_select_file (chooser, file, NULL);
1141   g_object_unref (file);
1142
1143   return result;
1144 }
1145
1146 /**
1147  * gtk_file_chooser_unselect_filename:
1148  * @chooser: a #GtkFileChooser
1149  * @filename: the filename to unselect
1150  * 
1151  * Unselects a currently selected filename. If the filename
1152  * is not in the current directory, does not exist, or
1153  * is otherwise not currently selected, does nothing.
1154  *
1155  * Since: 2.4
1156  **/
1157 void
1158 gtk_file_chooser_unselect_filename (GtkFileChooser *chooser,
1159                                     const char     *filename)
1160 {
1161   GFile *file;
1162
1163   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1164   g_return_if_fail (filename != NULL);
1165
1166   file = g_file_new_for_path (filename);
1167   gtk_file_chooser_unselect_file (chooser, file);
1168   g_object_unref (file);
1169 }
1170
1171 /* Converts a list of GFile* to a list of strings using the specified function */
1172 static GSList *
1173 files_to_strings (GSList  *files,
1174                   gchar * (*convert_func) (GFile *file))
1175 {
1176   GSList *strings;
1177
1178   strings = NULL;
1179
1180   for (; files; files = files->next)
1181     {
1182       GFile *file;
1183       gchar *string;
1184
1185       file = files->data;
1186       string = (* convert_func) (file);
1187
1188       if (string)
1189         strings = g_slist_prepend (strings, string);
1190     }
1191
1192   return g_slist_reverse (strings);
1193 }
1194
1195 /**
1196  * gtk_file_chooser_get_filenames:
1197  * @chooser: a #GtkFileChooser
1198  * 
1199  * Lists all the selected files and subfolders in the current folder of
1200  * @chooser. The returned names are full absolute paths. If files in the current
1201  * folder cannot be represented as local filenames they will be ignored. (See
1202  * gtk_file_chooser_get_uris())
1203  *
1204  * Return value: (element-type utf8) (transfer full): a #GSList containing the filenames of all selected
1205  *   files and subfolders in the current folder. Free the returned list
1206  *   with g_slist_free(), and the filenames with g_free().
1207  *
1208  * Since: 2.4
1209  **/
1210 GSList *
1211 gtk_file_chooser_get_filenames (GtkFileChooser *chooser)
1212 {
1213   GSList *files, *result;
1214   
1215   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1216
1217   files = gtk_file_chooser_get_files (chooser);
1218
1219   result = files_to_strings (files, g_file_get_path);
1220   g_slist_foreach (files, (GFunc) g_object_unref, NULL);
1221   g_slist_free (files);
1222
1223   return result;
1224 }
1225
1226 /**
1227  * gtk_file_chooser_set_current_folder:
1228  * @chooser: a #GtkFileChooser
1229  * @filename: the full path of the new current folder
1230  * 
1231  * Sets the current folder for @chooser from a local filename.
1232  * The user will be shown the full contents of the current folder,
1233  * plus user interface elements for navigating to other folders.
1234  *
1235  * Return value: %TRUE if the folder could be changed successfully, %FALSE
1236  * otherwise.
1237  *
1238  * Since: 2.4
1239  **/
1240 gboolean
1241 gtk_file_chooser_set_current_folder (GtkFileChooser *chooser,
1242                                      const gchar    *filename)
1243 {
1244   GFile *file;
1245   gboolean result;
1246   
1247   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1248   g_return_val_if_fail (filename != NULL, FALSE);
1249
1250   file = g_file_new_for_path (filename);
1251   result = gtk_file_chooser_set_current_folder_file (chooser, file, NULL);
1252   g_object_unref (file);
1253
1254   return result;
1255 }
1256
1257 /**
1258  * gtk_file_chooser_get_current_folder:
1259  * @chooser: a #GtkFileChooser
1260  * 
1261  * Gets the current folder of @chooser as a local filename.
1262  * See gtk_file_chooser_set_current_folder().
1263  *
1264  * Note that this is the folder that the file chooser is currently displaying
1265  * (e.g. "/home/username/Documents"), which is <emphasis>not the same</emphasis>
1266  * as the currently-selected folder if the chooser is in
1267  * %GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER mode
1268  * (e.g. "/home/username/Documents/selected-folder/".  To get the
1269  * currently-selected folder in that mode, use gtk_file_chooser_get_uri() as the
1270  * usual way to get the selection.
1271  * 
1272  * Return value: the full path of the current folder, or %NULL if the current
1273  * path cannot be represented as a local filename.  Free with g_free().  This
1274  * function will also return %NULL if the file chooser was unable to load the
1275  * last folder that was requested from it; for example, as would be for calling
1276  * gtk_file_chooser_set_current_folder() on a nonexistent folder.
1277  *
1278  * Since: 2.4
1279  **/
1280 gchar *
1281 gtk_file_chooser_get_current_folder (GtkFileChooser *chooser)
1282 {
1283   GFile *file;
1284   gchar *filename;
1285   
1286   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1287
1288   file = gtk_file_chooser_get_current_folder_file (chooser);
1289   if (!file)
1290     return NULL;
1291
1292   filename = g_file_get_path (file);
1293   g_object_unref (file);
1294
1295   return filename;
1296 }
1297
1298 /**
1299  * gtk_file_chooser_set_current_name:
1300  * @chooser: a #GtkFileChooser
1301  * @name: the filename to use, as a UTF-8 string
1302  * 
1303  * Sets the current name in the file selector, as if entered
1304  * by the user. Note that the name passed in here is a UTF-8
1305  * string rather than a filename. This function is meant for
1306  * such uses as a suggested name in a "Save As..." dialog.
1307  *
1308  * If you want to preselect a particular existing file, you should use
1309  * gtk_file_chooser_set_filename() or gtk_file_chooser_set_uri() instead.
1310  * Please see the documentation for those functions for an example of using
1311  * gtk_file_chooser_set_current_name() as well.
1312  *
1313  * Since: 2.4
1314  **/
1315 void
1316 gtk_file_chooser_set_current_name  (GtkFileChooser *chooser,
1317                                     const gchar    *name)
1318 {
1319   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1320   g_return_if_fail (name != NULL);
1321   
1322   GTK_FILE_CHOOSER_GET_IFACE (chooser)->set_current_name (chooser, name);
1323 }
1324
1325 /**
1326  * gtk_file_chooser_get_uri:
1327  * @chooser: a #GtkFileChooser
1328  * 
1329  * Gets the URI for the currently selected file in
1330  * the file selector. If multiple files are selected,
1331  * one of the filenames will be returned at random.
1332  * 
1333  * If the file chooser is in folder mode, this function returns the selected
1334  * folder.
1335  * 
1336  * Return value: The currently selected URI, or %NULL
1337  *  if no file is selected. Free with g_free()
1338  *
1339  * Since: 2.4
1340  **/
1341 gchar *
1342 gtk_file_chooser_get_uri (GtkFileChooser *chooser)
1343 {
1344   GFile *file;
1345   gchar *result = NULL;
1346   
1347   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1348
1349   file = gtk_file_chooser_get_file (chooser);
1350   if (file)
1351     {
1352       result = g_file_get_uri (file);
1353       g_object_unref (file);
1354     }
1355
1356   return result;
1357 }
1358
1359 /**
1360  * gtk_file_chooser_set_uri:
1361  * @chooser: a #GtkFileChooser
1362  * @uri: the URI to set as current
1363  * 
1364  * Sets the file referred to by @uri as the current file for the file chooser,
1365  * by changing to the URI's parent folder and actually selecting the URI in the
1366  * list.  If the @chooser is %GTK_FILE_CHOOSER_ACTION_SAVE mode, the URI's base
1367  * name will also appear in the dialog's file name entry.
1368  *
1369  * If the URI isn't in the current folder of @chooser, then the current folder
1370  * of @chooser will be changed to the folder containing @uri. This is equivalent
1371  * to a sequence of gtk_file_chooser_unselect_all() followed by
1372  * gtk_file_chooser_select_uri().
1373  *
1374  * Note that the URI must exist, or nothing will be done except for the 
1375  * directory change.
1376  * If you are implementing a <guimenuitem>File/Save As...</guimenuitem> dialog,
1377  * you should use this function if you already have a file name to which the 
1378  * user may save; for example, when the user opens an existing file and then 
1379  * does <guimenuitem>File/Save As...</guimenuitem> on it.  If you don't have 
1380  * a file name already &mdash; for example, if the user just created a new 
1381  * file and is saving it for the first time, do not call this function.  
1382  * Instead, use something similar to this:
1383  * |[
1384  * if (document_is_new)
1385  *   {
1386  *     /&ast; the user just created a new document &ast;/
1387  *     gtk_file_chooser_set_current_folder_uri (chooser, default_folder_for_saving);
1388  *     gtk_file_chooser_set_current_name (chooser, "Untitled document");
1389  *   }
1390  * else
1391  *   {
1392  *     /&ast; the user edited an existing document &ast;/ 
1393  *     gtk_file_chooser_set_uri (chooser, existing_uri);
1394  *   }
1395  * ]|
1396  *
1397  * Return value: %TRUE if both the folder could be changed and the URI was
1398  * selected successfully, %FALSE otherwise.
1399  *
1400  * Since: 2.4
1401  **/
1402 gboolean
1403 gtk_file_chooser_set_uri (GtkFileChooser *chooser,
1404                           const char     *uri)
1405 {
1406   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1407
1408   gtk_file_chooser_unselect_all (chooser);
1409   return gtk_file_chooser_select_uri (chooser, uri);
1410 }
1411
1412 /**
1413  * gtk_file_chooser_select_uri:
1414  * @chooser: a #GtkFileChooser
1415  * @uri: the URI to select
1416  * 
1417  * Selects the file to by @uri. If the URI doesn't refer to a
1418  * file in the current folder of @chooser, then the current folder of
1419  * @chooser will be changed to the folder containing @filename.
1420  *
1421  * Return value: %TRUE if both the folder could be changed and the URI was
1422  * selected successfully, %FALSE otherwise.
1423  *
1424  * Since: 2.4
1425  **/
1426 gboolean
1427 gtk_file_chooser_select_uri (GtkFileChooser *chooser,
1428                              const char     *uri)
1429 {
1430   GFile *file;
1431   gboolean result;
1432   
1433   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1434   g_return_val_if_fail (uri != NULL, FALSE);
1435
1436   file = g_file_new_for_uri (uri);
1437   result = gtk_file_chooser_select_file (chooser, file, NULL);
1438   g_object_unref (file);
1439
1440   return result;
1441 }
1442
1443 /**
1444  * gtk_file_chooser_unselect_uri:
1445  * @chooser: a #GtkFileChooser
1446  * @uri: the URI to unselect
1447  * 
1448  * Unselects the file referred to by @uri. If the file
1449  * is not in the current directory, does not exist, or
1450  * is otherwise not currently selected, does nothing.
1451  *
1452  * Since: 2.4
1453  **/
1454 void
1455 gtk_file_chooser_unselect_uri (GtkFileChooser *chooser,
1456                                const char     *uri)
1457 {
1458   GFile *file;
1459
1460   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1461   g_return_if_fail (uri != NULL);
1462
1463   file = g_file_new_for_uri (uri);
1464   gtk_file_chooser_unselect_file (chooser, file);
1465   g_object_unref (file);
1466 }
1467
1468 /**
1469  * gtk_file_chooser_select_all:
1470  * @chooser: a #GtkFileChooser
1471  * 
1472  * Selects all the files in the current folder of a file chooser.
1473  *
1474  * Since: 2.4
1475  **/
1476 void
1477 gtk_file_chooser_select_all (GtkFileChooser *chooser)
1478 {
1479   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1480   
1481   GTK_FILE_CHOOSER_GET_IFACE (chooser)->select_all (chooser);
1482 }
1483
1484 /**
1485  * gtk_file_chooser_unselect_all:
1486  * @chooser: a #GtkFileChooser
1487  * 
1488  * Unselects all the files in the current folder of a file chooser.
1489  *
1490  * Since: 2.4
1491  **/
1492 void
1493 gtk_file_chooser_unselect_all (GtkFileChooser *chooser)
1494 {
1495
1496   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1497   
1498   GTK_FILE_CHOOSER_GET_IFACE (chooser)->unselect_all (chooser);
1499 }
1500
1501 /**
1502  * gtk_file_chooser_get_uris:
1503  * @chooser: a #GtkFileChooser
1504  * 
1505  * Lists all the selected files and subfolders in the current folder of
1506  * @chooser. The returned names are full absolute URIs.
1507  *
1508  * Return value: (element-type utf8) (transfer full): a #GSList containing the URIs of all selected
1509  *   files and subfolders in the current folder. Free the returned list
1510  *   with g_slist_free(), and the filenames with g_free().
1511  *
1512  * Since: 2.4
1513  **/
1514 GSList *
1515 gtk_file_chooser_get_uris (GtkFileChooser *chooser)
1516 {
1517   GSList *files, *result;
1518   
1519   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1520
1521   files = gtk_file_chooser_get_files (chooser);
1522
1523   result = files_to_strings (files, g_file_get_uri);
1524   g_slist_foreach (files, (GFunc) g_object_unref, NULL);
1525   g_slist_free (files);
1526
1527   return result;
1528 }
1529
1530 /**
1531  * gtk_file_chooser_set_current_folder_uri:
1532  * @chooser: a #GtkFileChooser
1533  * @uri: the URI for the new current folder
1534  * 
1535  * Sets the current folder for @chooser from an URI.
1536  * The user will be shown the full contents of the current folder,
1537  * plus user interface elements for navigating to other folders.
1538  *
1539  * Return value: %TRUE if the folder could be changed successfully, %FALSE
1540  * otherwise.
1541  *
1542  * Since: 2.4
1543  **/
1544 gboolean
1545 gtk_file_chooser_set_current_folder_uri (GtkFileChooser *chooser,
1546                                          const gchar    *uri)
1547 {
1548   GFile *file;
1549   gboolean result;
1550   
1551   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1552   g_return_val_if_fail (uri != NULL, FALSE);
1553
1554   file = g_file_new_for_uri (uri);
1555   result = gtk_file_chooser_set_current_folder_file (chooser, file, NULL);
1556   g_object_unref (file);
1557
1558   return result;
1559 }
1560
1561 /**
1562  * gtk_file_chooser_get_current_folder_uri:
1563  * @chooser: a #GtkFileChooser
1564  *
1565  * Gets the current folder of @chooser as an URI.
1566  * See gtk_file_chooser_set_current_folder_uri().
1567  *
1568  * Note that this is the folder that the file chooser is currently displaying
1569  * (e.g. "file:///home/username/Documents"), which is <emphasis>not the same</emphasis>
1570  * as the currently-selected folder if the chooser is in
1571  * %GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER mode
1572  * (e.g. "file:///home/username/Documents/selected-folder/".  To get the
1573  * currently-selected folder in that mode, use gtk_file_chooser_get_uri() as the
1574  * usual way to get the selection.
1575  * 
1576  * Return value: the URI for the current folder.  Free with g_free().  This
1577  * function will also return %NULL if the file chooser was unable to load the
1578  * last folder that was requested from it; for example, as would be for calling
1579  * gtk_file_chooser_set_current_folder_uri() on a nonexistent folder.
1580  *
1581  * Since: 2.4
1582  */
1583 gchar *
1584 gtk_file_chooser_get_current_folder_uri (GtkFileChooser *chooser)
1585 {
1586   GFile *file;
1587   gchar *uri;
1588   
1589   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1590
1591   file = gtk_file_chooser_get_current_folder_file (chooser);
1592   if (!file)
1593     return NULL;
1594
1595   uri = g_file_get_uri (file);
1596   g_object_unref (file);
1597
1598   return uri;
1599 }
1600
1601 /**
1602  * gtk_file_chooser_set_current_folder_file:
1603  * @chooser: a #GtkFileChooser
1604  * @file: the #GFile for the new folder
1605  * @error: (allow-none): location to store error, or %NULL.
1606  *
1607  * Sets the current folder for @chooser from a #GFile.
1608  * Internal function, see gtk_file_chooser_set_current_folder_uri().
1609  *
1610  * Return value: %TRUE if the folder could be changed successfully, %FALSE
1611  * otherwise.
1612  *
1613  * Since: 2.14
1614  **/
1615 gboolean
1616 gtk_file_chooser_set_current_folder_file (GtkFileChooser  *chooser,
1617                                           GFile           *file,
1618                                           GError         **error)
1619 {
1620   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1621   g_return_val_if_fail (G_IS_FILE (file), FALSE);
1622   g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
1623
1624   return GTK_FILE_CHOOSER_GET_IFACE (chooser)->set_current_folder (chooser, file, error);
1625 }
1626
1627 /**
1628  * gtk_file_chooser_get_current_folder_file:
1629  * @chooser: a #GtkFileChooser
1630  *
1631  * Gets the current folder of @chooser as #GFile.
1632  * See gtk_file_chooser_get_current_folder_uri().
1633  *
1634  * Return value: (transfer full): the #GFile for the current folder.
1635  *
1636  * Since: 2.14
1637  */
1638 GFile *
1639 gtk_file_chooser_get_current_folder_file (GtkFileChooser *chooser)
1640 {
1641   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1642
1643   return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_current_folder (chooser);
1644 }
1645
1646 /**
1647  * gtk_file_chooser_select_file:
1648  * @chooser: a #GtkFileChooser
1649  * @file: the file to select
1650  * @error: (allow-none): location to store error, or %NULL
1651  * 
1652  * Selects the file referred to by @file. An internal function. See
1653  * _gtk_file_chooser_select_uri().
1654  *
1655  * Return value: %TRUE if both the folder could be changed and the path was
1656  * selected successfully, %FALSE otherwise.
1657  *
1658  * Since: 2.14
1659  **/
1660 gboolean
1661 gtk_file_chooser_select_file (GtkFileChooser  *chooser,
1662                               GFile           *file,
1663                               GError         **error)
1664 {
1665   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1666   g_return_val_if_fail (G_IS_FILE (file), FALSE);
1667   g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
1668
1669   return GTK_FILE_CHOOSER_GET_IFACE (chooser)->select_file (chooser, file, error);
1670 }
1671
1672 /**
1673  * gtk_file_chooser_unselect_file:
1674  * @chooser: a #GtkFileChooser
1675  * @file: a #GFile
1676  * 
1677  * Unselects the file referred to by @file. If the file is not in the current
1678  * directory, does not exist, or is otherwise not currently selected, does nothing.
1679  *
1680  * Since: 2.14
1681  **/
1682 void
1683 gtk_file_chooser_unselect_file (GtkFileChooser *chooser,
1684                                 GFile          *file)
1685 {
1686   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1687   g_return_if_fail (G_IS_FILE (file));
1688
1689   GTK_FILE_CHOOSER_GET_IFACE (chooser)->unselect_file (chooser, file);
1690 }
1691
1692 /**
1693  * gtk_file_chooser_get_files:
1694  * @chooser: a #GtkFileChooser
1695  * 
1696  * Lists all the selected files and subfolders in the current folder of @chooser
1697  * as #GFile. An internal function, see gtk_file_chooser_get_uris().
1698  *
1699  * Return value: (element-type utf8) (transfer full): a #GSList containing a #GFile for each selected
1700  *   file and subfolder in the current folder.  Free the returned list
1701  *   with g_slist_free(), and the files with g_object_unref().
1702  *
1703  * Since: 2.14
1704  **/
1705 GSList *
1706 gtk_file_chooser_get_files (GtkFileChooser *chooser)
1707 {
1708   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1709
1710   return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_files (chooser);
1711 }
1712
1713 /**
1714  * gtk_file_chooser_set_file:
1715  * @chooser: a #GtkFileChooser
1716  * @file: the #GFile to set as current
1717  * @error: (allow-none): location to store the error, or %NULL to ignore errors.
1718  *
1719  * Sets @file as the current filename for the file chooser, by changing
1720  * to the file's parent folder and actually selecting the file in list.  If
1721  * the @chooser is in %GTK_FILE_CHOOSER_ACTION_SAVE mode, the file's base name
1722  * will also appear in the dialog's file name entry.
1723  *
1724  * If the file name isn't in the current folder of @chooser, then the current
1725  * folder of @chooser will be changed to the folder containing @filename. This
1726  * is equivalent to a sequence of gtk_file_chooser_unselect_all() followed by
1727  * gtk_file_chooser_select_filename().
1728  *
1729  * Note that the file must exist, or nothing will be done except
1730  * for the directory change.
1731  *
1732  * If you are implementing a <guimenuitem>File/Save As...</guimenuitem> dialog,
1733  * you should use this function if you already have a file name to which the
1734  * user may save; for example, when the user opens an existing file and then
1735  * does <guimenuitem>File/Save As...</guimenuitem> on it.  If you don't have
1736  * a file name already &mdash; for example, if the user just created a new
1737  * file and is saving it for the first time, do not call this function.
1738  * Instead, use something similar to this:
1739  * |[
1740  * if (document_is_new)
1741  *   {
1742  *     /&ast; the user just created a new document &ast;/
1743  *     gtk_file_chooser_set_current_folder_file (chooser, default_file_for_saving);
1744  *     gtk_file_chooser_set_current_name (chooser, "Untitled document");
1745  *   }
1746  * else
1747  *   {
1748  *     /&ast; the user edited an existing document &ast;/
1749  *     gtk_file_chooser_set_file (chooser, existing_file);
1750  *   }
1751  * ]|
1752  *
1753  * Return value: %TRUE if both the folder could be changed and the file was
1754  * selected successfully, %FALSE otherwise.
1755  *
1756  * Since: 2.14
1757  **/
1758 gboolean
1759 gtk_file_chooser_set_file (GtkFileChooser  *chooser,
1760                            GFile           *file,
1761                            GError         **error)
1762 {
1763   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1764   g_return_val_if_fail (G_IS_FILE (file), FALSE);
1765   g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
1766
1767   gtk_file_chooser_unselect_all (chooser);
1768   return gtk_file_chooser_select_file (chooser, file, error);
1769 }
1770
1771 /**
1772  * gtk_file_chooser_get_file:
1773  * @chooser: a #GtkFileChooser
1774  *
1775  * Gets the #GFile for the currently selected file in
1776  * the file selector. If multiple files are selected,
1777  * one of the files will be returned at random.
1778  *
1779  * If the file chooser is in folder mode, this function returns the selected
1780  * folder.
1781  *
1782  * Returns: (transfer full): a selected #GFile. You own the returned file;
1783  *     use g_object_unref() to release it.
1784  *
1785  * Since: 2.14
1786  **/
1787 GFile *
1788 gtk_file_chooser_get_file (GtkFileChooser *chooser)
1789 {
1790   GSList *list;
1791   GFile *result = NULL;
1792   
1793   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1794
1795   list = gtk_file_chooser_get_files (chooser);
1796   if (list)
1797     {
1798       result = list->data;
1799       list = g_slist_delete_link (list, list);
1800
1801       g_slist_foreach (list, (GFunc) g_object_unref, NULL);
1802       g_slist_free (list);
1803     }
1804
1805   return result;
1806 }
1807
1808 /**
1809  * _gtk_file_chooser_get_file_system:
1810  * @chooser: a #GtkFileChooser
1811  * 
1812  * Gets the #GtkFileSystem of @chooser; this is an internal
1813  * implementation detail, used for conversion between paths
1814  * and filenames and URIs.
1815  * 
1816  * Return value: the file system for @chooser.
1817  *
1818  * Since: 2.4
1819  **/
1820 GtkFileSystem *
1821 _gtk_file_chooser_get_file_system (GtkFileChooser *chooser)
1822 {
1823   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1824
1825   return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_file_system (chooser);
1826 }
1827
1828 /* Preview widget
1829  */
1830 /**
1831  * gtk_file_chooser_set_preview_widget:
1832  * @chooser: a #GtkFileChooser
1833  * @preview_widget: widget for displaying preview.
1834  *
1835  * Sets an application-supplied widget to use to display a custom preview
1836  * of the currently selected file. To implement a preview, after setting the
1837  * preview widget, you connect to the #GtkFileChooser::update-preview
1838  * signal, and call gtk_file_chooser_get_preview_filename() or
1839  * gtk_file_chooser_get_preview_uri() on each change. If you can
1840  * display a preview of the new file, update your widget and
1841  * set the preview active using gtk_file_chooser_set_preview_widget_active().
1842  * Otherwise, set the preview inactive.
1843  *
1844  * When there is no application-supplied preview widget, or the
1845  * application-supplied preview widget is not active, the file chooser
1846  * may display an internally generated preview of the current file or
1847  * it may display no preview at all.
1848  *
1849  * Since: 2.4
1850  **/
1851 void
1852 gtk_file_chooser_set_preview_widget (GtkFileChooser *chooser,
1853                                      GtkWidget      *preview_widget)
1854 {
1855   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1856
1857   g_object_set (chooser, "preview-widget", preview_widget, NULL);
1858 }
1859
1860 /**
1861  * gtk_file_chooser_get_preview_widget:
1862  * @chooser: a #GtkFileChooser
1863  *
1864  * Gets the current preview widget; see
1865  * gtk_file_chooser_set_preview_widget().
1866  *
1867  * Return value: (transfer none): the current preview widget, or %NULL
1868  *
1869  * Since: 2.4
1870  **/
1871 GtkWidget *
1872 gtk_file_chooser_get_preview_widget (GtkFileChooser *chooser)
1873 {
1874   GtkWidget *preview_widget;
1875   
1876   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1877
1878   g_object_get (chooser, "preview-widget", &preview_widget, NULL);
1879   
1880   /* Horrid hack; g_object_get() refs returned objects but
1881    * that contradicts the memory management conventions
1882    * for accessors.
1883    */
1884   if (preview_widget)
1885     g_object_unref (preview_widget);
1886
1887   return preview_widget;
1888 }
1889
1890 /**
1891  * gtk_file_chooser_set_preview_widget_active:
1892  * @chooser: a #GtkFileChooser
1893  * @active: whether to display the user-specified preview widget
1894  * 
1895  * Sets whether the preview widget set by
1896  * gtk_file_chooser_set_preview_widget() should be shown for the
1897  * current filename. When @active is set to false, the file chooser
1898  * may display an internally generated preview of the current file
1899  * or it may display no preview at all. See
1900  * gtk_file_chooser_set_preview_widget() for more details.
1901  *
1902  * Since: 2.4
1903  **/
1904 void
1905 gtk_file_chooser_set_preview_widget_active (GtkFileChooser *chooser,
1906                                             gboolean        active)
1907 {
1908   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1909   
1910   g_object_set (chooser, "preview-widget-active", active, NULL);
1911 }
1912
1913 /**
1914  * gtk_file_chooser_get_preview_widget_active:
1915  * @chooser: a #GtkFileChooser
1916  * 
1917  * Gets whether the preview widget set by gtk_file_chooser_set_preview_widget()
1918  * should be shown for the current filename. See
1919  * gtk_file_chooser_set_preview_widget_active().
1920  * 
1921  * Return value: %TRUE if the preview widget is active for the current filename.
1922  *
1923  * Since: 2.4
1924  **/
1925 gboolean
1926 gtk_file_chooser_get_preview_widget_active (GtkFileChooser *chooser)
1927 {
1928   gboolean active;
1929   
1930   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1931
1932   g_object_get (chooser, "preview-widget-active", &active, NULL);
1933
1934   return active;
1935 }
1936
1937 /**
1938  * gtk_file_chooser_set_use_preview_label:
1939  * @chooser: a #GtkFileChooser
1940  * @use_label: whether to display a stock label with the name of the previewed file
1941  * 
1942  * Sets whether the file chooser should display a stock label with the name of
1943  * the file that is being previewed; the default is %TRUE.  Applications that
1944  * want to draw the whole preview area themselves should set this to %FALSE and
1945  * display the name themselves in their preview widget.
1946  *
1947  * See also: gtk_file_chooser_set_preview_widget()
1948  *
1949  * Since: 2.4
1950  **/
1951 void
1952 gtk_file_chooser_set_use_preview_label (GtkFileChooser *chooser,
1953                                         gboolean        use_label)
1954 {
1955   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1956
1957   g_object_set (chooser, "use-preview-label", use_label, NULL);
1958 }
1959
1960 /**
1961  * gtk_file_chooser_get_use_preview_label:
1962  * @chooser: a #GtkFileChooser
1963  * 
1964  * Gets whether a stock label should be drawn with the name of the previewed
1965  * file.  See gtk_file_chooser_set_use_preview_label().
1966  * 
1967  * Return value: %TRUE if the file chooser is set to display a label with the
1968  * name of the previewed file, %FALSE otherwise.
1969  **/
1970 gboolean
1971 gtk_file_chooser_get_use_preview_label (GtkFileChooser *chooser)
1972 {
1973   gboolean use_label;
1974   
1975   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1976
1977   g_object_get (chooser, "use-preview-label", &use_label, NULL);
1978
1979   return use_label;
1980 }
1981
1982 /**
1983  * gtk_file_chooser_get_preview_file:
1984  * @chooser: a #GtkFileChooser
1985  *
1986  * Gets the #GFile that should be previewed in a custom preview
1987  * Internal function, see gtk_file_chooser_get_preview_uri().
1988  *
1989  * Return value: (transfer none): the #GFile for the file to preview,
1990  *     or %NULL if no file is selected. Free with g_object_unref().
1991  *
1992  * Since: 2.14
1993  **/
1994 GFile *
1995 gtk_file_chooser_get_preview_file (GtkFileChooser *chooser)
1996 {
1997   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1998
1999   return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_preview_file (chooser);
2000 }
2001
2002 /**
2003  * _gtk_file_chooser_add_shortcut_folder:
2004  * @chooser: a #GtkFileChooser
2005  * @file: file for the folder to add
2006  * @error: (allow-none): location to store error, or %NULL
2007  * 
2008  * Adds a folder to be displayed with the shortcut folders in a file chooser.
2009  * Internal function, see gtk_file_chooser_add_shortcut_folder().
2010  * 
2011  * Return value: %TRUE if the folder could be added successfully, %FALSE
2012  * otherwise.
2013  *
2014  * Since: 2.4
2015  **/
2016 gboolean
2017 _gtk_file_chooser_add_shortcut_folder (GtkFileChooser  *chooser,
2018                                        GFile           *file,
2019                                        GError         **error)
2020 {
2021   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2022   g_return_val_if_fail (G_IS_FILE (file), FALSE);
2023
2024   return GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_shortcut_folder (chooser, file, error);
2025 }
2026
2027 /**
2028  * _gtk_file_chooser_remove_shortcut_folder:
2029  * @chooser: a #GtkFileChooser
2030  * @file: file for the folder to remove
2031  * @error: (allow-none): location to store error, or %NULL
2032  * 
2033  * Removes a folder from the shortcut folders in a file chooser.  Internal
2034  * function, see gtk_file_chooser_remove_shortcut_folder().
2035  * 
2036  * Return value: %TRUE if the folder could be removed successfully, %FALSE
2037  * otherwise.
2038  *
2039  * Since: 2.4
2040  **/
2041 gboolean
2042 _gtk_file_chooser_remove_shortcut_folder (GtkFileChooser  *chooser,
2043                                           GFile           *file,
2044                                           GError         **error)
2045 {
2046   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2047   g_return_val_if_fail (G_IS_FILE (file), FALSE);
2048
2049   return GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_shortcut_folder (chooser, file, error);
2050 }
2051
2052 /**
2053  * gtk_file_chooser_get_preview_filename:
2054  * @chooser: a #GtkFileChooser
2055  * 
2056  * Gets the filename that should be previewed in a custom preview
2057  * widget. See gtk_file_chooser_set_preview_widget().
2058  * 
2059  * Return value: the filename to preview, or %NULL if no file
2060  *  is selected, or if the selected file cannot be represented
2061  *  as a local filename. Free with g_free()
2062  *
2063  * Since: 2.4
2064  **/
2065 char *
2066 gtk_file_chooser_get_preview_filename (GtkFileChooser *chooser)
2067 {
2068   GFile *file;
2069   gchar *result = NULL;
2070   
2071   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2072
2073   file = gtk_file_chooser_get_preview_file (chooser);
2074   if (file)
2075     {
2076       result = g_file_get_path (file);
2077       g_object_unref (file);
2078     }
2079
2080   return result;
2081 }
2082
2083 /**
2084  * gtk_file_chooser_get_preview_uri:
2085  * @chooser: a #GtkFileChooser
2086  * 
2087  * Gets the URI that should be previewed in a custom preview
2088  * widget. See gtk_file_chooser_set_preview_widget().
2089  * 
2090  * Return value: the URI for the file to preview, or %NULL if no file is
2091  * selected. Free with g_free().
2092  *
2093  * Since: 2.4
2094  **/
2095 char *
2096 gtk_file_chooser_get_preview_uri (GtkFileChooser *chooser)
2097 {
2098   GFile *file;
2099   gchar *result = NULL;
2100   
2101   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2102
2103   file = gtk_file_chooser_get_preview_file (chooser);
2104   if (file)
2105     {
2106       result = g_file_get_uri (file);
2107       g_object_unref (file);
2108     }
2109
2110   return result;
2111 }
2112
2113 /**
2114  * gtk_file_chooser_set_extra_widget:
2115  * @chooser: a #GtkFileChooser
2116  * @extra_widget: widget for extra options
2117  * 
2118  * Sets an application-supplied widget to provide extra options to the user.
2119  *
2120  * Since: 2.4
2121  **/
2122 void
2123 gtk_file_chooser_set_extra_widget (GtkFileChooser *chooser,
2124                                    GtkWidget      *extra_widget)
2125 {
2126   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
2127
2128   g_object_set (chooser, "extra-widget", extra_widget, NULL);
2129 }
2130
2131 /**
2132  * gtk_file_chooser_get_extra_widget:
2133  * @chooser: a #GtkFileChooser
2134  *
2135  * Gets the current preview widget; see
2136  * gtk_file_chooser_set_extra_widget().
2137  *
2138  * Return value: (transfer none): the current extra widget, or %NULL
2139  *
2140  * Since: 2.4
2141  **/
2142 GtkWidget *
2143 gtk_file_chooser_get_extra_widget (GtkFileChooser *chooser)
2144 {
2145   GtkWidget *extra_widget;
2146   
2147   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2148
2149   g_object_get (chooser, "extra-widget", &extra_widget, NULL);
2150   
2151   /* Horrid hack; g_object_get() refs returned objects but
2152    * that contradicts the memory management conventions
2153    * for accessors.
2154    */
2155   if (extra_widget)
2156     g_object_unref (extra_widget);
2157
2158   return extra_widget;
2159 }
2160
2161 /**
2162  * gtk_file_chooser_add_filter:
2163  * @chooser: a #GtkFileChooser
2164  * @filter: a #GtkFileFilter
2165  * 
2166  * Adds @filter to the list of filters that the user can select between.
2167  * When a filter is selected, only files that are passed by that
2168  * filter are displayed. 
2169  * 
2170  * Note that the @chooser takes ownership of the filter, so you have to 
2171  * ref and sink it if you want to keep a reference.
2172  *
2173  * Since: 2.4
2174  **/
2175 void
2176 gtk_file_chooser_add_filter (GtkFileChooser *chooser,
2177                              GtkFileFilter  *filter)
2178 {
2179   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
2180
2181   GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_filter (chooser, filter);
2182 }
2183
2184 /**
2185  * gtk_file_chooser_remove_filter:
2186  * @chooser: a #GtkFileChooser
2187  * @filter: a #GtkFileFilter
2188  * 
2189  * Removes @filter from the list of filters that the user can select between.
2190  *
2191  * Since: 2.4
2192  **/
2193 void
2194 gtk_file_chooser_remove_filter (GtkFileChooser *chooser,
2195                                 GtkFileFilter  *filter)
2196 {
2197   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
2198
2199   GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_filter (chooser, filter);
2200 }
2201
2202 /**
2203  * gtk_file_chooser_list_filters:
2204  * @chooser: a #GtkFileChooser
2205  * 
2206  * Lists the current set of user-selectable filters; see
2207  * gtk_file_chooser_add_filter(), gtk_file_chooser_remove_filter().
2208  *
2209  * Return value: (element-type utf8) (transfer container): a #GSList containing the current set of
2210  *  user selectable filters. The contents of the list are
2211  *  owned by GTK+, but you must free the list itself with
2212  *  g_slist_free() when you are done with it.
2213  *
2214  * Since: 2.4
2215  **/
2216 GSList *
2217 gtk_file_chooser_list_filters  (GtkFileChooser *chooser)
2218 {
2219   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2220
2221   return GTK_FILE_CHOOSER_GET_IFACE (chooser)->list_filters (chooser);
2222 }
2223
2224 /**
2225  * gtk_file_chooser_set_filter:
2226  * @chooser: a #GtkFileChooser
2227  * @filter: a #GtkFileFilter
2228  * 
2229  * Sets the current filter; only the files that pass the
2230  * filter will be displayed. If the user-selectable list of filters
2231  * is non-empty, then the filter should be one of the filters
2232  * in that list. Setting the current filter when the list of
2233  * filters is empty is useful if you want to restrict the displayed
2234  * set of files without letting the user change it.
2235  *
2236  * Since: 2.4
2237  **/
2238 void
2239 gtk_file_chooser_set_filter (GtkFileChooser *chooser,
2240                              GtkFileFilter  *filter)
2241 {
2242   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
2243   g_return_if_fail (GTK_IS_FILE_FILTER (filter));
2244
2245   g_object_set (chooser, "filter", filter, NULL);
2246 }
2247
2248 /**
2249  * gtk_file_chooser_get_filter:
2250  * @chooser: a #GtkFileChooser
2251  *
2252  * Gets the current filter; see gtk_file_chooser_set_filter().
2253  *
2254  * Return value: (transfer none): the current filter, or %NULL
2255  *
2256  * Since: 2.4
2257  **/
2258 GtkFileFilter *
2259 gtk_file_chooser_get_filter (GtkFileChooser *chooser)
2260 {
2261   GtkFileFilter *filter;
2262   
2263   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2264
2265   g_object_get (chooser, "filter", &filter, NULL);
2266   /* Horrid hack; g_object_get() refs returned objects but
2267    * that contradicts the memory management conventions
2268    * for accessors.
2269    */
2270   if (filter)
2271     g_object_unref (filter);
2272
2273   return filter;
2274 }
2275
2276 /**
2277  * gtk_file_chooser_add_shortcut_folder:
2278  * @chooser: a #GtkFileChooser
2279  * @folder: filename of the folder to add
2280  * @error: (allow-none): location to store error, or %NULL
2281  * 
2282  * Adds a folder to be displayed with the shortcut folders in a file chooser.
2283  * Note that shortcut folders do not get saved, as they are provided by the
2284  * application.  For example, you can use this to add a
2285  * "/usr/share/mydrawprogram/Clipart" folder to the volume list.
2286  * 
2287  * Return value: %TRUE if the folder could be added successfully, %FALSE
2288  * otherwise.  In the latter case, the @error will be set as appropriate.
2289  *
2290  * Since: 2.4
2291  **/
2292 gboolean
2293 gtk_file_chooser_add_shortcut_folder (GtkFileChooser    *chooser,
2294                                       const char        *folder,
2295                                       GError           **error)
2296 {
2297   GFile *file;
2298   gboolean result;
2299
2300   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2301   g_return_val_if_fail (folder != NULL, FALSE);
2302
2303   file = g_file_new_for_path (folder);
2304   result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_shortcut_folder (chooser, file, error);
2305   g_object_unref (file);
2306
2307   return result;
2308 }
2309
2310 /**
2311  * gtk_file_chooser_remove_shortcut_folder:
2312  * @chooser: a #GtkFileChooser
2313  * @folder: filename of the folder to remove
2314  * @error: (allow-none): location to store error, or %NULL
2315  * 
2316  * Removes a folder from a file chooser's list of shortcut folders.
2317  * 
2318  * Return value: %TRUE if the operation succeeds, %FALSE otherwise.  
2319  * In the latter case, the @error will be set as appropriate.
2320  *
2321  * See also: gtk_file_chooser_add_shortcut_folder()
2322  *
2323  * Since: 2.4
2324  **/
2325 gboolean
2326 gtk_file_chooser_remove_shortcut_folder (GtkFileChooser    *chooser,
2327                                          const char        *folder,
2328                                          GError           **error)
2329 {
2330   GFile *file;
2331   gboolean result;
2332
2333   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2334   g_return_val_if_fail (folder != NULL, FALSE);
2335
2336   file = g_file_new_for_path (folder);
2337   result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_shortcut_folder (chooser, file, error);
2338   g_object_unref (file);
2339
2340   return result;
2341 }
2342
2343 /**
2344  * gtk_file_chooser_list_shortcut_folders:
2345  * @chooser: a #GtkFileChooser
2346  * 
2347  * Queries the list of shortcut folders in the file chooser, as set by
2348  * gtk_file_chooser_add_shortcut_folder().
2349  *
2350  * Return value: (element-type utf8) (transfer full): A list of folder filenames, or %NULL if there are no shortcut
2351  * folders.  Free the returned list with g_slist_free(), and the filenames with
2352  * g_free().
2353  *
2354  * Since: 2.4
2355  **/
2356 GSList *
2357 gtk_file_chooser_list_shortcut_folders (GtkFileChooser *chooser)
2358 {
2359   GSList *folders;
2360   GSList *result;
2361
2362   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2363
2364   folders = _gtk_file_chooser_list_shortcut_folder_files (chooser);
2365
2366   result = files_to_strings (folders, g_file_get_path);
2367   g_slist_foreach (folders, (GFunc) g_object_unref, NULL);
2368   g_slist_free (folders);
2369
2370   return result;
2371 }
2372
2373 /**
2374  * gtk_file_chooser_add_shortcut_folder_uri:
2375  * @chooser: a #GtkFileChooser
2376  * @uri: URI of the folder to add
2377  * @error: (allow-none): location to store error, or %NULL
2378  * 
2379  * Adds a folder URI to be displayed with the shortcut folders in a file
2380  * chooser.  Note that shortcut folders do not get saved, as they are provided
2381  * by the application.  For example, you can use this to add a
2382  * "file:///usr/share/mydrawprogram/Clipart" folder to the volume list.
2383  * 
2384  * Return value: %TRUE if the folder could be added successfully, %FALSE
2385  * otherwise.  In the latter case, the @error will be set as appropriate.
2386  *
2387  * Since: 2.4
2388  **/
2389 gboolean
2390 gtk_file_chooser_add_shortcut_folder_uri (GtkFileChooser    *chooser,
2391                                           const char        *uri,
2392                                           GError           **error)
2393 {
2394   GFile *file;
2395   gboolean result;
2396
2397   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2398   g_return_val_if_fail (uri != NULL, FALSE);
2399
2400   file = g_file_new_for_uri (uri);
2401   result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_shortcut_folder (chooser, file, error);
2402   g_object_unref (file);
2403
2404   return result;
2405 }
2406
2407 /**
2408  * gtk_file_chooser_remove_shortcut_folder_uri:
2409  * @chooser: a #GtkFileChooser
2410  * @uri: URI of the folder to remove
2411  * @error: (allow-none): location to store error, or %NULL
2412  * 
2413  * Removes a folder URI from a file chooser's list of shortcut folders.
2414  * 
2415  * Return value: %TRUE if the operation succeeds, %FALSE otherwise.  
2416  * In the latter case, the @error will be set as appropriate.
2417  *
2418  * See also: gtk_file_chooser_add_shortcut_folder_uri()
2419  *
2420  * Since: 2.4
2421  **/
2422 gboolean
2423 gtk_file_chooser_remove_shortcut_folder_uri (GtkFileChooser    *chooser,
2424                                              const char        *uri,
2425                                              GError           **error)
2426 {
2427   GFile *file;
2428   gboolean result;
2429
2430   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2431   g_return_val_if_fail (uri != NULL, FALSE);
2432
2433   file = g_file_new_for_uri (uri);
2434   result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_shortcut_folder (chooser, file, error);
2435   g_object_unref (file);
2436
2437   return result;
2438 }
2439
2440 /**
2441  * gtk_file_chooser_list_shortcut_folder_uris:
2442  * @chooser: a #GtkFileChooser
2443  * 
2444  * Queries the list of shortcut folders in the file chooser, as set by
2445  * gtk_file_chooser_add_shortcut_folder_uri().
2446  *
2447  * Return value: (element-type utf8) (transfer full): A list of folder URIs, or %NULL if there are no shortcut
2448  * folders.  Free the returned list with g_slist_free(), and the URIs with
2449  * g_free().
2450  *
2451  * Since: 2.4
2452  **/
2453 GSList *
2454 gtk_file_chooser_list_shortcut_folder_uris (GtkFileChooser *chooser)
2455 {
2456   GSList *folders;
2457   GSList *result;
2458
2459   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2460
2461   folders = _gtk_file_chooser_list_shortcut_folder_files (chooser);
2462
2463   result = files_to_strings (folders, g_file_get_uri);
2464   g_slist_foreach (folders, (GFunc) g_object_unref, NULL);
2465   g_slist_free (folders);
2466
2467   return result;
2468 }
2469
2470 GSList *
2471 _gtk_file_chooser_list_shortcut_folder_files (GtkFileChooser *chooser)
2472 {
2473   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2474
2475   return GTK_FILE_CHOOSER_GET_IFACE (chooser)->list_shortcut_folders (chooser);
2476 }
2477
2478 /**
2479  * gtk_file_chooser_set_show_hidden:
2480  * @chooser: a #GtkFileChooser
2481  * @show_hidden: %TRUE if hidden files and folders should be displayed.
2482  * 
2483  * Sets whether hidden files and folders are displayed in the file selector.  
2484  *
2485  * Since: 2.6
2486  **/
2487 void
2488 gtk_file_chooser_set_show_hidden (GtkFileChooser *chooser,
2489                                   gboolean        show_hidden)
2490 {
2491   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
2492
2493   g_object_set (chooser, "show-hidden", show_hidden, NULL);
2494 }
2495
2496 /**
2497  * gtk_file_chooser_get_show_hidden:
2498  * @chooser: a #GtkFileChooser
2499  * 
2500  * Gets whether hidden files and folders are displayed in the file selector.   
2501  * See gtk_file_chooser_set_show_hidden().
2502  * 
2503  * Return value: %TRUE if hidden files and folders are displayed.
2504  *
2505  * Since: 2.6
2506  **/
2507 gboolean
2508 gtk_file_chooser_get_show_hidden (GtkFileChooser *chooser)
2509 {
2510   gboolean show_hidden;
2511   
2512   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2513
2514   g_object_get (chooser, "show-hidden", &show_hidden, NULL);
2515
2516   return show_hidden;
2517 }
2518
2519 /**
2520  * gtk_file_chooser_set_do_overwrite_confirmation:
2521  * @chooser: a #GtkFileChooser
2522  * @do_overwrite_confirmation: whether to confirm overwriting in save mode
2523  * 
2524  * Sets whether a file chooser in %GTK_FILE_CHOOSER_ACTION_SAVE mode will present
2525  * a confirmation dialog if the user types a file name that already exists.  This
2526  * is %FALSE by default.
2527  *
2528  * Regardless of this setting, the @chooser will emit the
2529  * #GtkFileChooser::confirm-overwrite signal when appropriate.
2530  *
2531  * If all you need is the stock confirmation dialog, set this property to %TRUE.
2532  * You can override the way confirmation is done by actually handling the
2533  * #GtkFileChooser::confirm-overwrite signal; please refer to its documentation
2534  * for the details.
2535  *
2536  * Since: 2.8
2537  **/
2538 void
2539 gtk_file_chooser_set_do_overwrite_confirmation (GtkFileChooser *chooser,
2540                                                 gboolean        do_overwrite_confirmation)
2541 {
2542   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
2543
2544   g_object_set (chooser, "do-overwrite-confirmation", do_overwrite_confirmation, NULL);
2545 }
2546
2547 /**
2548  * gtk_file_chooser_get_do_overwrite_confirmation:
2549  * @chooser: a #GtkFileChooser
2550  * 
2551  * Queries whether a file chooser is set to confirm for overwriting when the user
2552  * types a file name that already exists.
2553  * 
2554  * Return value: %TRUE if the file chooser will present a confirmation dialog;
2555  * %FALSE otherwise.
2556  *
2557  * Since: 2.8
2558  **/
2559 gboolean
2560 gtk_file_chooser_get_do_overwrite_confirmation (GtkFileChooser *chooser)
2561 {
2562   gboolean do_overwrite_confirmation;
2563
2564   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2565
2566   g_object_get (chooser, "do-overwrite-confirmation", &do_overwrite_confirmation, NULL);
2567
2568   return do_overwrite_confirmation;
2569 }