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