]> Pileus Git - ~andy/gtk/blob - gtk/gtkfilechooser.c
stylecontext: Do invalidation on first resize container
[~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  * On some systems non-native files may still be
911  * available using the native filesystem via a userspace
912  * filesystem (FUSE).
913  *
914  * Since: 2.4
915  **/
916 void
917 gtk_file_chooser_set_local_only (GtkFileChooser *chooser,
918                                  gboolean        local_only)
919 {
920   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
921
922   g_object_set (chooser, "local-only", local_only, NULL);
923 }
924
925 /**
926  * gtk_file_chooser_get_local_only:
927  * @chooser: a #GtkFileChooser
928  * 
929  * Gets whether only local files can be selected in the
930  * file selector. See gtk_file_chooser_set_local_only()
931  * 
932  * Return value: %TRUE if only local files can be selected.
933  *
934  * Since: 2.4
935  **/
936 gboolean
937 gtk_file_chooser_get_local_only (GtkFileChooser *chooser)
938 {
939   gboolean local_only;
940   
941   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
942
943   g_object_get (chooser, "local-only", &local_only, NULL);
944
945   return local_only;
946 }
947
948 /**
949  * gtk_file_chooser_set_select_multiple:
950  * @chooser: a #GtkFileChooser
951  * @select_multiple: %TRUE if multiple files can be selected.
952  * 
953  * Sets whether multiple files can be selected in the file selector.  This is
954  * only relevant if the action is set to be %GTK_FILE_CHOOSER_ACTION_OPEN or
955  * %GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER.
956  *
957  * Since: 2.4
958  **/
959 void
960 gtk_file_chooser_set_select_multiple (GtkFileChooser *chooser,
961                                       gboolean        select_multiple)
962 {
963   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
964
965   g_object_set (chooser, "select-multiple", select_multiple, NULL);
966 }
967
968 /**
969  * gtk_file_chooser_get_select_multiple:
970  * @chooser: a #GtkFileChooser
971  * 
972  * Gets whether multiple files can be selected in the file
973  * selector. See gtk_file_chooser_set_select_multiple().
974  * 
975  * Return value: %TRUE if multiple files can be selected.
976  *
977  * Since: 2.4
978  **/
979 gboolean
980 gtk_file_chooser_get_select_multiple (GtkFileChooser *chooser)
981 {
982   gboolean select_multiple;
983   
984   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
985
986   g_object_get (chooser, "select-multiple", &select_multiple, NULL);
987
988   return select_multiple;
989 }
990
991 /**
992  * gtk_file_chooser_set_create_folders:
993  * @chooser: a #GtkFileChooser
994  * @create_folders: %TRUE if the New Folder button should be displayed
995  * 
996  * Sets whether file choser will offer to create new folders.
997  * This is only relevant if the action is not set to be 
998  * %GTK_FILE_CHOOSER_ACTION_OPEN.
999  *
1000  * Since: 2.18
1001  **/
1002 void
1003 gtk_file_chooser_set_create_folders (GtkFileChooser *chooser,
1004                                      gboolean        create_folders)
1005 {
1006   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1007
1008   g_object_set (chooser, "create-folders", create_folders, NULL);
1009 }
1010
1011 /**
1012  * gtk_file_chooser_get_create_folders:
1013  * @chooser: a #GtkFileChooser
1014  * 
1015  * Gets whether file choser will offer to create new folders.
1016  * See gtk_file_chooser_set_create_folders().
1017  * 
1018  * Return value: %TRUE if the New Folder button should be displayed.
1019  *
1020  * Since: 2.18
1021  **/
1022 gboolean
1023 gtk_file_chooser_get_create_folders (GtkFileChooser *chooser)
1024 {
1025   gboolean create_folders;
1026   
1027   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1028
1029   g_object_get (chooser, "create-folders", &create_folders, NULL);
1030
1031   return create_folders;
1032 }
1033
1034 /**
1035  * gtk_file_chooser_get_filename:
1036  * @chooser: a #GtkFileChooser
1037  * 
1038  * Gets the filename for the currently selected file in
1039  * the file selector. The filename is returned as an absolute path. If
1040  * multiple files are selected, one of the filenames will be returned at
1041  * random.
1042  *
1043  * If the file chooser is in folder mode, this function returns the selected
1044  * folder.
1045  * 
1046  * Return value: (type filename): The currently selected filename, or %NULL
1047  *  if no file is selected, or the selected file can't
1048  *  be represented with a local filename. Free with g_free().
1049  *
1050  * Since: 2.4
1051  **/
1052 gchar *
1053 gtk_file_chooser_get_filename (GtkFileChooser *chooser)
1054 {
1055   GFile *file;
1056   gchar *result = NULL;
1057
1058   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1059
1060   file = gtk_file_chooser_get_file (chooser);
1061
1062   if (file)
1063     {
1064       result = g_file_get_path (file);
1065       g_object_unref (file);
1066     }
1067
1068   return result;
1069 }
1070
1071 /**
1072  * gtk_file_chooser_set_filename:
1073  * @chooser: a #GtkFileChooser
1074  * @filename: (type filename): the filename to set as current
1075  * 
1076  * Sets @filename as the current filename for the file chooser, by changing to
1077  * the file's parent folder and actually selecting the file in list; all other
1078  * files will be unselected.  If the @chooser is in
1079  * %GTK_FILE_CHOOSER_ACTION_SAVE mode, the file's base name will also appear in
1080  * the dialog's file name entry.
1081  *
1082  * Note that the file must exist, or nothing will be done except
1083  * for the directory change.
1084  *
1085  * You should use this function only when implementing a <guimenuitem>File/Save
1086  * As...</guimenuitem> dialog for which you already have a file name to which
1087  * the user may save.  For example, when the user opens an existing file and
1088  * then does <guimenuitem>File/Save As...</guimenuitem> on it to save a copy or
1089  * a modified version.  If you don't have a file name already &mdash; for
1090  * example, if the user just created a new file and is saving it for the first
1091  * time, do not call this function.  Instead, use something similar to this:
1092  * |[
1093  * if (document_is_new)
1094  *   {
1095  *     /&ast; the user just created a new document &ast;/
1096  *     gtk_file_chooser_set_current_name (chooser, "Untitled document");
1097  *   }
1098  * else
1099  *   {
1100  *     /&ast; the user edited an existing document &ast;/ 
1101  *     gtk_file_chooser_set_filename (chooser, existing_filename);
1102  *   }
1103  * ]|
1104  *
1105  * In the first case, the file chooser will present the user with useful suggestions
1106  * as to where to save his new file.  In the second case, the file's existing location
1107  * is already known, so the file chooser will use it.
1108  * 
1109  * Return value: Not useful.
1110  *
1111  * Since: 2.4
1112  **/
1113 gboolean
1114 gtk_file_chooser_set_filename (GtkFileChooser *chooser,
1115                                const gchar    *filename)
1116 {
1117   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1118
1119   gtk_file_chooser_unselect_all (chooser);
1120   return gtk_file_chooser_select_filename (chooser, filename);
1121 }
1122
1123 /**
1124  * gtk_file_chooser_select_filename:
1125  * @chooser: a #GtkFileChooser
1126  * @filename: (type filename): the filename to select
1127  * 
1128  * Selects a filename. If the file name isn't in the current
1129  * folder of @chooser, then the current folder of @chooser will
1130  * be changed to the folder containing @filename.
1131  *
1132  * Return value: Not useful.
1133  *
1134  * See also: gtk_file_chooser_set_filename()
1135  *
1136  * Since: 2.4
1137  **/
1138 gboolean
1139 gtk_file_chooser_select_filename (GtkFileChooser *chooser,
1140                                   const gchar    *filename)
1141 {
1142   GFile *file;
1143   gboolean result;
1144   
1145   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1146   g_return_val_if_fail (filename != NULL, FALSE);
1147
1148   file = g_file_new_for_path (filename);
1149   result = gtk_file_chooser_select_file (chooser, file, NULL);
1150   g_object_unref (file);
1151
1152   return result;
1153 }
1154
1155 /**
1156  * gtk_file_chooser_unselect_filename:
1157  * @chooser: a #GtkFileChooser
1158  * @filename: (type filename): the filename to unselect
1159  * 
1160  * Unselects a currently selected filename. If the filename
1161  * is not in the current directory, does not exist, or
1162  * is otherwise not currently selected, does nothing.
1163  *
1164  * Since: 2.4
1165  **/
1166 void
1167 gtk_file_chooser_unselect_filename (GtkFileChooser *chooser,
1168                                     const char     *filename)
1169 {
1170   GFile *file;
1171
1172   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1173   g_return_if_fail (filename != NULL);
1174
1175   file = g_file_new_for_path (filename);
1176   gtk_file_chooser_unselect_file (chooser, file);
1177   g_object_unref (file);
1178 }
1179
1180 /* Converts a list of GFile* to a list of strings using the specified function */
1181 static GSList *
1182 files_to_strings (GSList  *files,
1183                   gchar * (*convert_func) (GFile *file))
1184 {
1185   GSList *strings;
1186
1187   strings = NULL;
1188
1189   for (; files; files = files->next)
1190     {
1191       GFile *file;
1192       gchar *string;
1193
1194       file = files->data;
1195       string = (* convert_func) (file);
1196
1197       if (string)
1198         strings = g_slist_prepend (strings, string);
1199     }
1200
1201   return g_slist_reverse (strings);
1202 }
1203
1204 static gchar *
1205 file_to_uri_with_native_path (GFile *file)
1206 {
1207   gchar *result = NULL;
1208   gchar *native;
1209
1210   native = g_file_get_path (file);
1211   if (native)
1212     {
1213       result = g_filename_to_uri (native, NULL, NULL); /* NULL-GError */
1214       g_free (native);
1215     }
1216
1217   return result;
1218 }
1219
1220 /**
1221  * gtk_file_chooser_get_filenames:
1222  * @chooser: a #GtkFileChooser
1223  * 
1224  * Lists all the selected files and subfolders in the current folder of
1225  * @chooser. The returned names are full absolute paths. If files in the current
1226  * folder cannot be represented as local filenames they will be ignored. (See
1227  * gtk_file_chooser_get_uris())
1228  *
1229  * Return value: (element-type filename) (transfer full): a #GSList
1230  *    containing the filenames of all selected files and subfolders in
1231  *    the current folder. Free the returned list with g_slist_free(),
1232  *    and the filenames with g_free().
1233  *
1234  * Since: 2.4
1235  **/
1236 GSList *
1237 gtk_file_chooser_get_filenames (GtkFileChooser *chooser)
1238 {
1239   GSList *files, *result;
1240   
1241   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1242
1243   files = gtk_file_chooser_get_files (chooser);
1244
1245   result = files_to_strings (files, g_file_get_path);
1246   g_slist_foreach (files, (GFunc) g_object_unref, NULL);
1247   g_slist_free (files);
1248
1249   return result;
1250 }
1251
1252 /**
1253  * gtk_file_chooser_set_current_folder:
1254  * @chooser: a #GtkFileChooser
1255  * @filename: (type filename): the full path of the new current folder
1256  * 
1257  * Sets the current folder for @chooser from a local filename.
1258  * The user will be shown the full contents of the current folder,
1259  * plus user interface elements for navigating to other folders.
1260  *
1261  * In general, you should not use this function.  See the <link
1262  * linkend="gtkfilechooserdialog-setting-up">section on setting up a file
1263  * chooser dialog</link> for the rationale behind this.
1264  *
1265  * Return value: Not useful.
1266  *
1267  * Since: 2.4
1268  **/
1269 gboolean
1270 gtk_file_chooser_set_current_folder (GtkFileChooser *chooser,
1271                                      const gchar    *filename)
1272 {
1273   GFile *file;
1274   gboolean result;
1275   
1276   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1277   g_return_val_if_fail (filename != NULL, FALSE);
1278
1279   file = g_file_new_for_path (filename);
1280   result = gtk_file_chooser_set_current_folder_file (chooser, file, NULL);
1281   g_object_unref (file);
1282
1283   return result;
1284 }
1285
1286 /**
1287  * gtk_file_chooser_get_current_folder:
1288  * @chooser: a #GtkFileChooser
1289  * 
1290  * Gets the current folder of @chooser as a local filename.
1291  * See gtk_file_chooser_set_current_folder().
1292  *
1293  * Note that this is the folder that the file chooser is currently displaying
1294  * (e.g. "/home/username/Documents"), which is <emphasis>not the same</emphasis>
1295  * as the currently-selected folder if the chooser is in
1296  * %GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER mode
1297  * (e.g. "/home/username/Documents/selected-folder/".  To get the
1298  * currently-selected folder in that mode, use gtk_file_chooser_get_uri() as the
1299  * usual way to get the selection.
1300  * 
1301  * Return value: (type filename): the full path of the current folder,
1302  * or %NULL if the current path cannot be represented as a local
1303  * filename.  Free with g_free().  This function will also return
1304  * %NULL if the file chooser was unable to load the last folder that
1305  * was requested from it; for example, as would be for calling
1306  * gtk_file_chooser_set_current_folder() on a nonexistent folder.
1307  *
1308  * Since: 2.4
1309  **/
1310 gchar *
1311 gtk_file_chooser_get_current_folder (GtkFileChooser *chooser)
1312 {
1313   GFile *file;
1314   gchar *filename;
1315   
1316   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1317
1318   file = gtk_file_chooser_get_current_folder_file (chooser);
1319   if (!file)
1320     return NULL;
1321
1322   filename = g_file_get_path (file);
1323   g_object_unref (file);
1324
1325   return filename;
1326 }
1327
1328 /**
1329  * gtk_file_chooser_set_current_name:
1330  * @chooser: a #GtkFileChooser
1331  * @name: (type filename): the filename to use, as a UTF-8 string
1332  * 
1333  * Sets the current name in the file selector, as if entered
1334  * by the user. Note that the name passed in here is a UTF-8
1335  * string rather than a filename. This function is meant for
1336  * such uses as a suggested name in a "Save As..." dialog.  You can
1337  * pass "Untitled.doc" or a similarly suitable suggestion for the @name.
1338  *
1339  * If you want to preselect a particular existing file, you should use
1340  * gtk_file_chooser_set_filename() or gtk_file_chooser_set_uri() instead.
1341  * Please see the documentation for those functions for an example of using
1342  * gtk_file_chooser_set_current_name() as well.
1343  *
1344  * Since: 2.4
1345  **/
1346 void
1347 gtk_file_chooser_set_current_name  (GtkFileChooser *chooser,
1348                                     const gchar    *name)
1349 {
1350   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1351   g_return_if_fail (name != NULL);
1352   
1353   GTK_FILE_CHOOSER_GET_IFACE (chooser)->set_current_name (chooser, name);
1354 }
1355
1356 /**
1357  * gtk_file_chooser_get_uri:
1358  * @chooser: a #GtkFileChooser
1359  * 
1360  * Gets the URI for the currently selected file in
1361  * the file selector. If multiple files are selected,
1362  * one of the filenames will be returned at random.
1363  * 
1364  * If the file chooser is in folder mode, this function returns the selected
1365  * folder.
1366  * 
1367  * Return value: The currently selected URI, or %NULL
1368  *  if no file is selected. If gtk_file_chooser_set_local_only() is set to %TRUE
1369  * (the default) a local URI will be returned for any FUSE locations.
1370  * Free with g_free()
1371  *
1372  * Since: 2.4
1373  **/
1374 gchar *
1375 gtk_file_chooser_get_uri (GtkFileChooser *chooser)
1376 {
1377   GFile *file;
1378   gchar *result = NULL;
1379   
1380   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1381
1382   file = gtk_file_chooser_get_file (chooser);
1383   if (file)
1384     {
1385       if (gtk_file_chooser_get_local_only (chooser))
1386           result = file_to_uri_with_native_path (file);
1387       else 
1388           result = g_file_get_uri (file);
1389
1390       g_object_unref (file);
1391     }
1392
1393   return result;
1394 }
1395
1396 /**
1397  * gtk_file_chooser_set_uri:
1398  * @chooser: a #GtkFileChooser
1399  * @uri: the URI to set as current
1400  * 
1401  * Sets the file referred to by @uri as the current file for the file chooser,
1402  * by changing to the URI's parent folder and actually selecting the URI in the
1403  * list.  If the @chooser is %GTK_FILE_CHOOSER_ACTION_SAVE mode, the URI's base
1404  * name will also appear in the dialog's file name entry.
1405  *
1406  * Note that the URI must exist, or nothing will be done except for the 
1407  * directory change.
1408  *
1409  * You should use this function only when implementing a <guimenuitem>File/Save
1410  * As...</guimenuitem> dialog for which you already have a file name to which
1411  * the user may save.  For example, whenthe user opens an existing file and then
1412  * does <guimenuitem>File/Save As...</guimenuitem> on it to save a copy or a
1413  * modified version.  If you don't have a file name already &mdash; for example,
1414  * if the user just created a new file and is saving it for the first time, do
1415  * not call this function.  Instead, use something similar to this:
1416  * |[
1417  * if (document_is_new)
1418  *   {
1419  *     /&ast; the user just created a new document &ast;/
1420  *     gtk_file_chooser_set_current_name (chooser, "Untitled document");
1421  *   }
1422  * else
1423  *   {
1424  *     /&ast; the user edited an existing document &ast;/ 
1425  *     gtk_file_chooser_set_uri (chooser, existing_uri);
1426  *   }
1427  * ]|
1428  *
1429  *
1430  * In the first case, the file chooser will present the user with useful suggestions
1431  * as to where to save his new file.  In the second case, the file's existing location
1432  * is already known, so the file chooser will use it.
1433  * 
1434  * Return value: Not useful.
1435  *
1436  * Since: 2.4
1437  **/
1438 gboolean
1439 gtk_file_chooser_set_uri (GtkFileChooser *chooser,
1440                           const char     *uri)
1441 {
1442   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1443
1444   gtk_file_chooser_unselect_all (chooser);
1445   return gtk_file_chooser_select_uri (chooser, uri);
1446 }
1447
1448 /**
1449  * gtk_file_chooser_select_uri:
1450  * @chooser: a #GtkFileChooser
1451  * @uri: the URI to select
1452  * 
1453  * Selects the file to by @uri. If the URI doesn't refer to a
1454  * file in the current folder of @chooser, then the current folder of
1455  * @chooser will be changed to the folder containing @filename.
1456  *
1457  * Return value: Not useful.
1458  *
1459  * Since: 2.4
1460  **/
1461 gboolean
1462 gtk_file_chooser_select_uri (GtkFileChooser *chooser,
1463                              const char     *uri)
1464 {
1465   GFile *file;
1466   gboolean result;
1467   
1468   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1469   g_return_val_if_fail (uri != NULL, FALSE);
1470
1471   file = g_file_new_for_uri (uri);
1472   result = gtk_file_chooser_select_file (chooser, file, NULL);
1473   g_object_unref (file);
1474
1475   return result;
1476 }
1477
1478 /**
1479  * gtk_file_chooser_unselect_uri:
1480  * @chooser: a #GtkFileChooser
1481  * @uri: the URI to unselect
1482  * 
1483  * Unselects the file referred to by @uri. If the file
1484  * is not in the current directory, does not exist, or
1485  * is otherwise not currently selected, does nothing.
1486  *
1487  * Since: 2.4
1488  **/
1489 void
1490 gtk_file_chooser_unselect_uri (GtkFileChooser *chooser,
1491                                const char     *uri)
1492 {
1493   GFile *file;
1494
1495   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1496   g_return_if_fail (uri != NULL);
1497
1498   file = g_file_new_for_uri (uri);
1499   gtk_file_chooser_unselect_file (chooser, file);
1500   g_object_unref (file);
1501 }
1502
1503 /**
1504  * gtk_file_chooser_select_all:
1505  * @chooser: a #GtkFileChooser
1506  * 
1507  * Selects all the files in the current folder of a file chooser.
1508  *
1509  * Since: 2.4
1510  **/
1511 void
1512 gtk_file_chooser_select_all (GtkFileChooser *chooser)
1513 {
1514   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1515   
1516   GTK_FILE_CHOOSER_GET_IFACE (chooser)->select_all (chooser);
1517 }
1518
1519 /**
1520  * gtk_file_chooser_unselect_all:
1521  * @chooser: a #GtkFileChooser
1522  * 
1523  * Unselects all the files in the current folder of a file chooser.
1524  *
1525  * Since: 2.4
1526  **/
1527 void
1528 gtk_file_chooser_unselect_all (GtkFileChooser *chooser)
1529 {
1530
1531   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1532   
1533   GTK_FILE_CHOOSER_GET_IFACE (chooser)->unselect_all (chooser);
1534 }
1535
1536 /**
1537  * gtk_file_chooser_get_uris:
1538  * @chooser: a #GtkFileChooser
1539  * 
1540  * Lists all the selected files and subfolders in the current folder of
1541  * @chooser. The returned names are full absolute URIs.
1542  *
1543  * Return value: (element-type utf8) (transfer full): a #GSList containing the URIs of all selected
1544  *   files and subfolders in the current folder. Free the returned list
1545  *   with g_slist_free(), and the filenames with g_free().
1546  *
1547  * Since: 2.4
1548  **/
1549 GSList *
1550 gtk_file_chooser_get_uris (GtkFileChooser *chooser)
1551 {
1552   GSList *files, *result;
1553   
1554   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1555
1556   files = gtk_file_chooser_get_files (chooser);
1557
1558   if (gtk_file_chooser_get_local_only (chooser))
1559     result = files_to_strings (files, file_to_uri_with_native_path);
1560   else
1561     result = files_to_strings (files, g_file_get_uri);
1562
1563   g_slist_foreach (files, (GFunc) g_object_unref, NULL);
1564   g_slist_free (files);
1565
1566   return result;
1567 }
1568
1569 /**
1570  * gtk_file_chooser_set_current_folder_uri:
1571  * @chooser: a #GtkFileChooser
1572  * @uri: the URI for the new current folder
1573  * 
1574  * Sets the current folder for @chooser from an URI.
1575  * The user will be shown the full contents of the current folder,
1576  * plus user interface elements for navigating to other folders.
1577  *
1578  * In general, you should not use this function.  See the <link
1579  * linkend="gtkfilechooserdialog-setting-up">section on setting up a file
1580  * chooser dialog</link> for the rationale behind this.
1581  *
1582  * Return value: %TRUE if the folder could be changed successfully, %FALSE
1583  * otherwise.
1584  *
1585  * Since: 2.4
1586  **/
1587 gboolean
1588 gtk_file_chooser_set_current_folder_uri (GtkFileChooser *chooser,
1589                                          const gchar    *uri)
1590 {
1591   GFile *file;
1592   gboolean result;
1593   
1594   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1595   g_return_val_if_fail (uri != NULL, FALSE);
1596
1597   file = g_file_new_for_uri (uri);
1598   result = gtk_file_chooser_set_current_folder_file (chooser, file, NULL);
1599   g_object_unref (file);
1600
1601   return result;
1602 }
1603
1604 /**
1605  * gtk_file_chooser_get_current_folder_uri:
1606  * @chooser: a #GtkFileChooser
1607  *
1608  * Gets the current folder of @chooser as an URI.
1609  * See gtk_file_chooser_set_current_folder_uri().
1610  *
1611  * Note that this is the folder that the file chooser is currently displaying
1612  * (e.g. "file:///home/username/Documents"), which is <emphasis>not the same</emphasis>
1613  * as the currently-selected folder if the chooser is in
1614  * %GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER mode
1615  * (e.g. "file:///home/username/Documents/selected-folder/".  To get the
1616  * currently-selected folder in that mode, use gtk_file_chooser_get_uri() as the
1617  * usual way to get the selection.
1618  * 
1619  * Return value: the URI for the current folder.  Free with g_free().  This
1620  * function will also return %NULL if the file chooser was unable to load the
1621  * last folder that was requested from it; for example, as would be for calling
1622  * gtk_file_chooser_set_current_folder_uri() on a nonexistent folder.
1623  *
1624  * Since: 2.4
1625  */
1626 gchar *
1627 gtk_file_chooser_get_current_folder_uri (GtkFileChooser *chooser)
1628 {
1629   GFile *file;
1630   gchar *uri;
1631   
1632   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1633
1634   file = gtk_file_chooser_get_current_folder_file (chooser);
1635   if (!file)
1636     return NULL;
1637
1638   uri = g_file_get_uri (file);
1639   g_object_unref (file);
1640
1641   return uri;
1642 }
1643
1644 /**
1645  * gtk_file_chooser_set_current_folder_file:
1646  * @chooser: a #GtkFileChooser
1647  * @file: the #GFile for the new folder
1648  * @error: (allow-none): location to store error, or %NULL.
1649  *
1650  * Sets the current folder for @chooser from a #GFile.
1651  * Internal function, see gtk_file_chooser_set_current_folder_uri().
1652  *
1653  * Return value: %TRUE if the folder could be changed successfully, %FALSE
1654  * otherwise.
1655  *
1656  * Since: 2.14
1657  **/
1658 gboolean
1659 gtk_file_chooser_set_current_folder_file (GtkFileChooser  *chooser,
1660                                           GFile           *file,
1661                                           GError         **error)
1662 {
1663   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1664   g_return_val_if_fail (G_IS_FILE (file), FALSE);
1665   g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
1666
1667   return GTK_FILE_CHOOSER_GET_IFACE (chooser)->set_current_folder (chooser, file, error);
1668 }
1669
1670 /**
1671  * gtk_file_chooser_get_current_folder_file:
1672  * @chooser: a #GtkFileChooser
1673  *
1674  * Gets the current folder of @chooser as #GFile.
1675  * See gtk_file_chooser_get_current_folder_uri().
1676  *
1677  * Return value: (transfer full): the #GFile for the current folder.
1678  *
1679  * Since: 2.14
1680  */
1681 GFile *
1682 gtk_file_chooser_get_current_folder_file (GtkFileChooser *chooser)
1683 {
1684   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1685
1686   return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_current_folder (chooser);
1687 }
1688
1689 /**
1690  * gtk_file_chooser_select_file:
1691  * @chooser: a #GtkFileChooser
1692  * @file: the file to select
1693  * @error: (allow-none): location to store error, or %NULL
1694  * 
1695  * Selects the file referred to by @file. An internal function. See
1696  * _gtk_file_chooser_select_uri().
1697  *
1698  * Return value: Not useful.
1699  *
1700  * Since: 2.14
1701  **/
1702 gboolean
1703 gtk_file_chooser_select_file (GtkFileChooser  *chooser,
1704                               GFile           *file,
1705                               GError         **error)
1706 {
1707   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1708   g_return_val_if_fail (G_IS_FILE (file), FALSE);
1709   g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
1710
1711   return GTK_FILE_CHOOSER_GET_IFACE (chooser)->select_file (chooser, file, error);
1712 }
1713
1714 /**
1715  * gtk_file_chooser_unselect_file:
1716  * @chooser: a #GtkFileChooser
1717  * @file: a #GFile
1718  * 
1719  * Unselects the file referred to by @file. If the file is not in the current
1720  * directory, does not exist, or is otherwise not currently selected, does nothing.
1721  *
1722  * Since: 2.14
1723  **/
1724 void
1725 gtk_file_chooser_unselect_file (GtkFileChooser *chooser,
1726                                 GFile          *file)
1727 {
1728   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1729   g_return_if_fail (G_IS_FILE (file));
1730
1731   GTK_FILE_CHOOSER_GET_IFACE (chooser)->unselect_file (chooser, file);
1732 }
1733
1734 /**
1735  * gtk_file_chooser_get_files:
1736  * @chooser: a #GtkFileChooser
1737  * 
1738  * Lists all the selected files and subfolders in the current folder of @chooser
1739  * as #GFile. An internal function, see gtk_file_chooser_get_uris().
1740  *
1741  * Return value: (element-type GFile) (transfer full): a #GSList
1742  *   containing a #GFile for each selected file and subfolder in the
1743  *   current folder.  Free the returned list with g_slist_free(), and
1744  *   the files with g_object_unref().
1745  *
1746  * Since: 2.14
1747  **/
1748 GSList *
1749 gtk_file_chooser_get_files (GtkFileChooser *chooser)
1750 {
1751   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1752
1753   return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_files (chooser);
1754 }
1755
1756 /**
1757  * gtk_file_chooser_set_file:
1758  * @chooser: a #GtkFileChooser
1759  * @file: the #GFile to set as current
1760  * @error: (allow-none): location to store the error, or %NULL to ignore errors.
1761  *
1762  * Sets @file as the current filename for the file chooser, by changing
1763  * to the file's parent folder and actually selecting the file in list.  If
1764  * the @chooser is in %GTK_FILE_CHOOSER_ACTION_SAVE mode, the file's base name
1765  * will also appear in the dialog's file name entry.
1766  *
1767  * If the file name isn't in the current folder of @chooser, then the current
1768  * folder of @chooser will be changed to the folder containing @filename. This
1769  * is equivalent to a sequence of gtk_file_chooser_unselect_all() followed by
1770  * gtk_file_chooser_select_filename().
1771  *
1772  * Note that the file must exist, or nothing will be done except
1773  * for the directory change.
1774  *
1775  * If you are implementing a <guimenuitem>File/Save As...</guimenuitem> dialog,
1776  * you should use this function if you already have a file name to which the
1777  * user may save; for example, when the user opens an existing file and then
1778  * does <guimenuitem>File/Save As...</guimenuitem> on it.  If you don't have
1779  * a file name already &mdash; for example, if the user just created a new
1780  * file and is saving it for the first time, do not call this function.
1781  * Instead, use something similar to this:
1782  * |[
1783  * if (document_is_new)
1784  *   {
1785  *     /&ast; the user just created a new document &ast;/
1786  *     gtk_file_chooser_set_current_folder_file (chooser, default_file_for_saving);
1787  *     gtk_file_chooser_set_current_name (chooser, "Untitled document");
1788  *   }
1789  * else
1790  *   {
1791  *     /&ast; the user edited an existing document &ast;/
1792  *     gtk_file_chooser_set_file (chooser, existing_file);
1793  *   }
1794  * ]|
1795  *
1796  * Return value: Not useful.
1797  *
1798  * Since: 2.14
1799  **/
1800 gboolean
1801 gtk_file_chooser_set_file (GtkFileChooser  *chooser,
1802                            GFile           *file,
1803                            GError         **error)
1804 {
1805   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1806   g_return_val_if_fail (G_IS_FILE (file), FALSE);
1807   g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
1808
1809   gtk_file_chooser_unselect_all (chooser);
1810   return gtk_file_chooser_select_file (chooser, file, error);
1811 }
1812
1813 /**
1814  * gtk_file_chooser_get_file:
1815  * @chooser: a #GtkFileChooser
1816  *
1817  * Gets the #GFile for the currently selected file in
1818  * the file selector. If multiple files are selected,
1819  * one of the files will be returned at random.
1820  *
1821  * If the file chooser is in folder mode, this function returns the selected
1822  * folder.
1823  *
1824  * Returns: (transfer full): a selected #GFile. You own the returned file;
1825  *     use g_object_unref() to release it.
1826  *
1827  * Since: 2.14
1828  **/
1829 GFile *
1830 gtk_file_chooser_get_file (GtkFileChooser *chooser)
1831 {
1832   GSList *list;
1833   GFile *result = NULL;
1834   
1835   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1836
1837   list = gtk_file_chooser_get_files (chooser);
1838   if (list)
1839     {
1840       result = list->data;
1841       list = g_slist_delete_link (list, list);
1842
1843       g_slist_foreach (list, (GFunc) g_object_unref, NULL);
1844       g_slist_free (list);
1845     }
1846
1847   return result;
1848 }
1849
1850 /**
1851  * _gtk_file_chooser_get_file_system:
1852  * @chooser: a #GtkFileChooser
1853  * 
1854  * Gets the #GtkFileSystem of @chooser; this is an internal
1855  * implementation detail, used for conversion between paths
1856  * and filenames and URIs.
1857  * 
1858  * Return value: the file system for @chooser.
1859  *
1860  * Since: 2.4
1861  **/
1862 GtkFileSystem *
1863 _gtk_file_chooser_get_file_system (GtkFileChooser *chooser)
1864 {
1865   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1866
1867   return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_file_system (chooser);
1868 }
1869
1870 /* Preview widget
1871  */
1872 /**
1873  * gtk_file_chooser_set_preview_widget:
1874  * @chooser: a #GtkFileChooser
1875  * @preview_widget: widget for displaying preview.
1876  *
1877  * Sets an application-supplied widget to use to display a custom preview
1878  * of the currently selected file. To implement a preview, after setting the
1879  * preview widget, you connect to the #GtkFileChooser::update-preview
1880  * signal, and call gtk_file_chooser_get_preview_filename() or
1881  * gtk_file_chooser_get_preview_uri() on each change. If you can
1882  * display a preview of the new file, update your widget and
1883  * set the preview active using gtk_file_chooser_set_preview_widget_active().
1884  * Otherwise, set the preview inactive.
1885  *
1886  * When there is no application-supplied preview widget, or the
1887  * application-supplied preview widget is not active, the file chooser
1888  * may display an internally generated preview of the current file or
1889  * it may display no preview at all.
1890  *
1891  * Since: 2.4
1892  **/
1893 void
1894 gtk_file_chooser_set_preview_widget (GtkFileChooser *chooser,
1895                                      GtkWidget      *preview_widget)
1896 {
1897   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1898
1899   g_object_set (chooser, "preview-widget", preview_widget, NULL);
1900 }
1901
1902 /**
1903  * gtk_file_chooser_get_preview_widget:
1904  * @chooser: a #GtkFileChooser
1905  *
1906  * Gets the current preview widget; see
1907  * gtk_file_chooser_set_preview_widget().
1908  *
1909  * Return value: (transfer none): the current preview widget, or %NULL
1910  *
1911  * Since: 2.4
1912  **/
1913 GtkWidget *
1914 gtk_file_chooser_get_preview_widget (GtkFileChooser *chooser)
1915 {
1916   GtkWidget *preview_widget;
1917   
1918   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1919
1920   g_object_get (chooser, "preview-widget", &preview_widget, NULL);
1921   
1922   /* Horrid hack; g_object_get() refs returned objects but
1923    * that contradicts the memory management conventions
1924    * for accessors.
1925    */
1926   if (preview_widget)
1927     g_object_unref (preview_widget);
1928
1929   return preview_widget;
1930 }
1931
1932 /**
1933  * gtk_file_chooser_set_preview_widget_active:
1934  * @chooser: a #GtkFileChooser
1935  * @active: whether to display the user-specified preview widget
1936  * 
1937  * Sets whether the preview widget set by
1938  * gtk_file_chooser_set_preview_widget() should be shown for the
1939  * current filename. When @active is set to false, the file chooser
1940  * may display an internally generated preview of the current file
1941  * or it may display no preview at all. See
1942  * gtk_file_chooser_set_preview_widget() for more details.
1943  *
1944  * Since: 2.4
1945  **/
1946 void
1947 gtk_file_chooser_set_preview_widget_active (GtkFileChooser *chooser,
1948                                             gboolean        active)
1949 {
1950   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1951   
1952   g_object_set (chooser, "preview-widget-active", active, NULL);
1953 }
1954
1955 /**
1956  * gtk_file_chooser_get_preview_widget_active:
1957  * @chooser: a #GtkFileChooser
1958  * 
1959  * Gets whether the preview widget set by gtk_file_chooser_set_preview_widget()
1960  * should be shown for the current filename. See
1961  * gtk_file_chooser_set_preview_widget_active().
1962  * 
1963  * Return value: %TRUE if the preview widget is active for the current filename.
1964  *
1965  * Since: 2.4
1966  **/
1967 gboolean
1968 gtk_file_chooser_get_preview_widget_active (GtkFileChooser *chooser)
1969 {
1970   gboolean active;
1971   
1972   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1973
1974   g_object_get (chooser, "preview-widget-active", &active, NULL);
1975
1976   return active;
1977 }
1978
1979 /**
1980  * gtk_file_chooser_set_use_preview_label:
1981  * @chooser: a #GtkFileChooser
1982  * @use_label: whether to display a stock label with the name of the previewed file
1983  * 
1984  * Sets whether the file chooser should display a stock label with the name of
1985  * the file that is being previewed; the default is %TRUE.  Applications that
1986  * want to draw the whole preview area themselves should set this to %FALSE and
1987  * display the name themselves in their preview widget.
1988  *
1989  * See also: gtk_file_chooser_set_preview_widget()
1990  *
1991  * Since: 2.4
1992  **/
1993 void
1994 gtk_file_chooser_set_use_preview_label (GtkFileChooser *chooser,
1995                                         gboolean        use_label)
1996 {
1997   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1998
1999   g_object_set (chooser, "use-preview-label", use_label, NULL);
2000 }
2001
2002 /**
2003  * gtk_file_chooser_get_use_preview_label:
2004  * @chooser: a #GtkFileChooser
2005  * 
2006  * Gets whether a stock label should be drawn with the name of the previewed
2007  * file.  See gtk_file_chooser_set_use_preview_label().
2008  * 
2009  * Return value: %TRUE if the file chooser is set to display a label with the
2010  * name of the previewed file, %FALSE otherwise.
2011  **/
2012 gboolean
2013 gtk_file_chooser_get_use_preview_label (GtkFileChooser *chooser)
2014 {
2015   gboolean use_label;
2016   
2017   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2018
2019   g_object_get (chooser, "use-preview-label", &use_label, NULL);
2020
2021   return use_label;
2022 }
2023
2024 /**
2025  * gtk_file_chooser_get_preview_file:
2026  * @chooser: a #GtkFileChooser
2027  *
2028  * Gets the #GFile that should be previewed in a custom preview
2029  * Internal function, see gtk_file_chooser_get_preview_uri().
2030  *
2031  * Return value: (transfer full): the #GFile for the file to preview,
2032  *     or %NULL if no file is selected. Free with g_object_unref().
2033  *
2034  * Since: 2.14
2035  **/
2036 GFile *
2037 gtk_file_chooser_get_preview_file (GtkFileChooser *chooser)
2038 {
2039   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2040
2041   return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_preview_file (chooser);
2042 }
2043
2044 /**
2045  * _gtk_file_chooser_add_shortcut_folder:
2046  * @chooser: a #GtkFileChooser
2047  * @file: file for the folder to add
2048  * @error: (allow-none): location to store error, or %NULL
2049  * 
2050  * Adds a folder to be displayed with the shortcut folders in a file chooser.
2051  * Internal function, see gtk_file_chooser_add_shortcut_folder().
2052  * 
2053  * Return value: %TRUE if the folder could be added successfully, %FALSE
2054  * otherwise.
2055  *
2056  * Since: 2.4
2057  **/
2058 gboolean
2059 _gtk_file_chooser_add_shortcut_folder (GtkFileChooser  *chooser,
2060                                        GFile           *file,
2061                                        GError         **error)
2062 {
2063   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2064   g_return_val_if_fail (G_IS_FILE (file), FALSE);
2065
2066   return GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_shortcut_folder (chooser, file, error);
2067 }
2068
2069 /**
2070  * _gtk_file_chooser_remove_shortcut_folder:
2071  * @chooser: a #GtkFileChooser
2072  * @file: file for the folder to remove
2073  * @error: (allow-none): location to store error, or %NULL
2074  * 
2075  * Removes a folder from the shortcut folders in a file chooser.  Internal
2076  * function, see gtk_file_chooser_remove_shortcut_folder().
2077  * 
2078  * Return value: %TRUE if the folder could be removed successfully, %FALSE
2079  * otherwise.
2080  *
2081  * Since: 2.4
2082  **/
2083 gboolean
2084 _gtk_file_chooser_remove_shortcut_folder (GtkFileChooser  *chooser,
2085                                           GFile           *file,
2086                                           GError         **error)
2087 {
2088   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2089   g_return_val_if_fail (G_IS_FILE (file), FALSE);
2090
2091   return GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_shortcut_folder (chooser, file, error);
2092 }
2093
2094 /**
2095  * gtk_file_chooser_get_preview_filename:
2096  * @chooser: a #GtkFileChooser
2097  * 
2098  * Gets the filename that should be previewed in a custom preview
2099  * widget. See gtk_file_chooser_set_preview_widget().
2100  * 
2101  * Return value: (type filename): the filename to preview, or %NULL if
2102  *  no file is selected, or if the selected file cannot be represented
2103  *  as a local filename. Free with g_free()
2104  *
2105  * Since: 2.4
2106  **/
2107 char *
2108 gtk_file_chooser_get_preview_filename (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_path (file);
2119       g_object_unref (file);
2120     }
2121
2122   return result;
2123 }
2124
2125 /**
2126  * gtk_file_chooser_get_preview_uri:
2127  * @chooser: a #GtkFileChooser
2128  * 
2129  * Gets the URI that should be previewed in a custom preview
2130  * widget. See gtk_file_chooser_set_preview_widget().
2131  * 
2132  * Return value: the URI for the file to preview, or %NULL if no file is
2133  * selected. Free with g_free().
2134  *
2135  * Since: 2.4
2136  **/
2137 char *
2138 gtk_file_chooser_get_preview_uri (GtkFileChooser *chooser)
2139 {
2140   GFile *file;
2141   gchar *result = NULL;
2142   
2143   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2144
2145   file = gtk_file_chooser_get_preview_file (chooser);
2146   if (file)
2147     {
2148       result = g_file_get_uri (file);
2149       g_object_unref (file);
2150     }
2151
2152   return result;
2153 }
2154
2155 /**
2156  * gtk_file_chooser_set_extra_widget:
2157  * @chooser: a #GtkFileChooser
2158  * @extra_widget: widget for extra options
2159  * 
2160  * Sets an application-supplied widget to provide extra options to the user.
2161  *
2162  * Since: 2.4
2163  **/
2164 void
2165 gtk_file_chooser_set_extra_widget (GtkFileChooser *chooser,
2166                                    GtkWidget      *extra_widget)
2167 {
2168   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
2169
2170   g_object_set (chooser, "extra-widget", extra_widget, NULL);
2171 }
2172
2173 /**
2174  * gtk_file_chooser_get_extra_widget:
2175  * @chooser: a #GtkFileChooser
2176  *
2177  * Gets the current preview widget; see
2178  * gtk_file_chooser_set_extra_widget().
2179  *
2180  * Return value: (transfer none): the current extra widget, or %NULL
2181  *
2182  * Since: 2.4
2183  **/
2184 GtkWidget *
2185 gtk_file_chooser_get_extra_widget (GtkFileChooser *chooser)
2186 {
2187   GtkWidget *extra_widget;
2188   
2189   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2190
2191   g_object_get (chooser, "extra-widget", &extra_widget, NULL);
2192   
2193   /* Horrid hack; g_object_get() refs returned objects but
2194    * that contradicts the memory management conventions
2195    * for accessors.
2196    */
2197   if (extra_widget)
2198     g_object_unref (extra_widget);
2199
2200   return extra_widget;
2201 }
2202
2203 /**
2204  * gtk_file_chooser_add_filter:
2205  * @chooser: a #GtkFileChooser
2206  * @filter: a #GtkFileFilter
2207  * 
2208  * Adds @filter to the list of filters that the user can select between.
2209  * When a filter is selected, only files that are passed by that
2210  * filter are displayed. 
2211  * 
2212  * Note that the @chooser takes ownership of the filter, so you have to 
2213  * ref and sink it if you want to keep a reference.
2214  *
2215  * Since: 2.4
2216  **/
2217 void
2218 gtk_file_chooser_add_filter (GtkFileChooser *chooser,
2219                              GtkFileFilter  *filter)
2220 {
2221   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
2222
2223   GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_filter (chooser, filter);
2224 }
2225
2226 /**
2227  * gtk_file_chooser_remove_filter:
2228  * @chooser: a #GtkFileChooser
2229  * @filter: a #GtkFileFilter
2230  * 
2231  * Removes @filter from the list of filters that the user can select between.
2232  *
2233  * Since: 2.4
2234  **/
2235 void
2236 gtk_file_chooser_remove_filter (GtkFileChooser *chooser,
2237                                 GtkFileFilter  *filter)
2238 {
2239   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
2240
2241   GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_filter (chooser, filter);
2242 }
2243
2244 /**
2245  * gtk_file_chooser_list_filters:
2246  * @chooser: a #GtkFileChooser
2247  * 
2248  * Lists the current set of user-selectable filters; see
2249  * gtk_file_chooser_add_filter(), gtk_file_chooser_remove_filter().
2250  *
2251  * Return value: (element-type GtkFileFilter) (transfer container): a
2252  *  #GSList containing the current set of user selectable filters. The
2253  *  contents of the list are owned by GTK+, but you must free the list
2254  *  itself with g_slist_free() when you are done with it.
2255  *
2256  * Since: 2.4
2257  **/
2258 GSList *
2259 gtk_file_chooser_list_filters  (GtkFileChooser *chooser)
2260 {
2261   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2262
2263   return GTK_FILE_CHOOSER_GET_IFACE (chooser)->list_filters (chooser);
2264 }
2265
2266 /**
2267  * gtk_file_chooser_set_filter:
2268  * @chooser: a #GtkFileChooser
2269  * @filter: a #GtkFileFilter
2270  * 
2271  * Sets the current filter; only the files that pass the
2272  * filter will be displayed. If the user-selectable list of filters
2273  * is non-empty, then the filter should be one of the filters
2274  * in that list. Setting the current filter when the list of
2275  * filters is empty is useful if you want to restrict the displayed
2276  * set of files without letting the user change it.
2277  *
2278  * Since: 2.4
2279  **/
2280 void
2281 gtk_file_chooser_set_filter (GtkFileChooser *chooser,
2282                              GtkFileFilter  *filter)
2283 {
2284   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
2285   g_return_if_fail (GTK_IS_FILE_FILTER (filter));
2286
2287   g_object_set (chooser, "filter", filter, NULL);
2288 }
2289
2290 /**
2291  * gtk_file_chooser_get_filter:
2292  * @chooser: a #GtkFileChooser
2293  *
2294  * Gets the current filter; see gtk_file_chooser_set_filter().
2295  *
2296  * Return value: (transfer none): the current filter, or %NULL
2297  *
2298  * Since: 2.4
2299  **/
2300 GtkFileFilter *
2301 gtk_file_chooser_get_filter (GtkFileChooser *chooser)
2302 {
2303   GtkFileFilter *filter;
2304   
2305   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2306
2307   g_object_get (chooser, "filter", &filter, NULL);
2308   /* Horrid hack; g_object_get() refs returned objects but
2309    * that contradicts the memory management conventions
2310    * for accessors.
2311    */
2312   if (filter)
2313     g_object_unref (filter);
2314
2315   return filter;
2316 }
2317
2318 /**
2319  * gtk_file_chooser_add_shortcut_folder:
2320  * @chooser: a #GtkFileChooser
2321  * @folder: (type filename): filename of the folder to add
2322  * @error: (allow-none): location to store error, or %NULL
2323  * 
2324  * Adds a folder to be displayed with the shortcut folders in a file chooser.
2325  * Note that shortcut folders do not get saved, as they are provided by the
2326  * application.  For example, you can use this to add a
2327  * "/usr/share/mydrawprogram/Clipart" folder to the volume list.
2328  * 
2329  * Return value: %TRUE if the folder could be added successfully, %FALSE
2330  * otherwise.  In the latter case, the @error will be set as appropriate.
2331  *
2332  * Since: 2.4
2333  **/
2334 gboolean
2335 gtk_file_chooser_add_shortcut_folder (GtkFileChooser    *chooser,
2336                                       const char        *folder,
2337                                       GError           **error)
2338 {
2339   GFile *file;
2340   gboolean result;
2341
2342   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2343   g_return_val_if_fail (folder != NULL, FALSE);
2344
2345   file = g_file_new_for_path (folder);
2346   result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_shortcut_folder (chooser, file, error);
2347   g_object_unref (file);
2348
2349   return result;
2350 }
2351
2352 /**
2353  * gtk_file_chooser_remove_shortcut_folder:
2354  * @chooser: a #GtkFileChooser
2355  * @folder: (type filename): filename of the folder to remove
2356  * @error: (allow-none): location to store error, or %NULL
2357  * 
2358  * Removes a folder from a file chooser's list of shortcut folders.
2359  * 
2360  * Return value: %TRUE if the operation succeeds, %FALSE otherwise.  
2361  * In the latter case, the @error will be set as appropriate.
2362  *
2363  * See also: gtk_file_chooser_add_shortcut_folder()
2364  *
2365  * Since: 2.4
2366  **/
2367 gboolean
2368 gtk_file_chooser_remove_shortcut_folder (GtkFileChooser    *chooser,
2369                                          const char        *folder,
2370                                          GError           **error)
2371 {
2372   GFile *file;
2373   gboolean result;
2374
2375   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2376   g_return_val_if_fail (folder != NULL, FALSE);
2377
2378   file = g_file_new_for_path (folder);
2379   result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_shortcut_folder (chooser, file, error);
2380   g_object_unref (file);
2381
2382   return result;
2383 }
2384
2385 /**
2386  * gtk_file_chooser_list_shortcut_folders:
2387  * @chooser: a #GtkFileChooser
2388  * 
2389  * Queries the list of shortcut folders in the file chooser, as set by
2390  * gtk_file_chooser_add_shortcut_folder().
2391  *
2392  * Return value: (element-type filename) (transfer full): A list of
2393  * folder filenames, or %NULL if there are no shortcut folders.  Free
2394  * the returned list with g_slist_free(), and the filenames with
2395  * g_free().
2396  *
2397  * Since: 2.4
2398  **/
2399 GSList *
2400 gtk_file_chooser_list_shortcut_folders (GtkFileChooser *chooser)
2401 {
2402   GSList *folders;
2403   GSList *result;
2404
2405   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2406
2407   folders = _gtk_file_chooser_list_shortcut_folder_files (chooser);
2408
2409   result = files_to_strings (folders, g_file_get_path);
2410   g_slist_foreach (folders, (GFunc) g_object_unref, NULL);
2411   g_slist_free (folders);
2412
2413   return result;
2414 }
2415
2416 /**
2417  * gtk_file_chooser_add_shortcut_folder_uri:
2418  * @chooser: a #GtkFileChooser
2419  * @uri: URI of the folder to add
2420  * @error: (allow-none): location to store error, or %NULL
2421  * 
2422  * Adds a folder URI to be displayed with the shortcut folders in a file
2423  * chooser.  Note that shortcut folders do not get saved, as they are provided
2424  * by the application.  For example, you can use this to add a
2425  * "file:///usr/share/mydrawprogram/Clipart" folder to the volume list.
2426  * 
2427  * Return value: %TRUE if the folder could be added successfully, %FALSE
2428  * otherwise.  In the latter case, the @error will be set as appropriate.
2429  *
2430  * Since: 2.4
2431  **/
2432 gboolean
2433 gtk_file_chooser_add_shortcut_folder_uri (GtkFileChooser    *chooser,
2434                                           const char        *uri,
2435                                           GError           **error)
2436 {
2437   GFile *file;
2438   gboolean result;
2439
2440   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2441   g_return_val_if_fail (uri != NULL, FALSE);
2442
2443   file = g_file_new_for_uri (uri);
2444   result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_shortcut_folder (chooser, file, error);
2445   g_object_unref (file);
2446
2447   return result;
2448 }
2449
2450 /**
2451  * gtk_file_chooser_remove_shortcut_folder_uri:
2452  * @chooser: a #GtkFileChooser
2453  * @uri: URI of the folder to remove
2454  * @error: (allow-none): location to store error, or %NULL
2455  * 
2456  * Removes a folder URI from a file chooser's list of shortcut folders.
2457  * 
2458  * Return value: %TRUE if the operation succeeds, %FALSE otherwise.  
2459  * In the latter case, the @error will be set as appropriate.
2460  *
2461  * See also: gtk_file_chooser_add_shortcut_folder_uri()
2462  *
2463  * Since: 2.4
2464  **/
2465 gboolean
2466 gtk_file_chooser_remove_shortcut_folder_uri (GtkFileChooser    *chooser,
2467                                              const char        *uri,
2468                                              GError           **error)
2469 {
2470   GFile *file;
2471   gboolean result;
2472
2473   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2474   g_return_val_if_fail (uri != NULL, FALSE);
2475
2476   file = g_file_new_for_uri (uri);
2477   result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_shortcut_folder (chooser, file, error);
2478   g_object_unref (file);
2479
2480   return result;
2481 }
2482
2483 /**
2484  * gtk_file_chooser_list_shortcut_folder_uris:
2485  * @chooser: a #GtkFileChooser
2486  * 
2487  * Queries the list of shortcut folders in the file chooser, as set by
2488  * gtk_file_chooser_add_shortcut_folder_uri().
2489  *
2490  * Return value: (element-type utf8) (transfer full): A list of folder
2491  * URIs, or %NULL if there are no shortcut folders.  Free the returned
2492  * list with g_slist_free(), and the URIs with g_free().
2493  *
2494  * Since: 2.4
2495  **/
2496 GSList *
2497 gtk_file_chooser_list_shortcut_folder_uris (GtkFileChooser *chooser)
2498 {
2499   GSList *folders;
2500   GSList *result;
2501
2502   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2503
2504   folders = _gtk_file_chooser_list_shortcut_folder_files (chooser);
2505
2506   result = files_to_strings (folders, g_file_get_uri);
2507   g_slist_foreach (folders, (GFunc) g_object_unref, NULL);
2508   g_slist_free (folders);
2509
2510   return result;
2511 }
2512
2513 GSList *
2514 _gtk_file_chooser_list_shortcut_folder_files (GtkFileChooser *chooser)
2515 {
2516   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
2517
2518   return GTK_FILE_CHOOSER_GET_IFACE (chooser)->list_shortcut_folders (chooser);
2519 }
2520
2521 /**
2522  * gtk_file_chooser_set_show_hidden:
2523  * @chooser: a #GtkFileChooser
2524  * @show_hidden: %TRUE if hidden files and folders should be displayed.
2525  * 
2526  * Sets whether hidden files and folders are displayed in the file selector.  
2527  *
2528  * Since: 2.6
2529  **/
2530 void
2531 gtk_file_chooser_set_show_hidden (GtkFileChooser *chooser,
2532                                   gboolean        show_hidden)
2533 {
2534   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
2535
2536   g_object_set (chooser, "show-hidden", show_hidden, NULL);
2537 }
2538
2539 /**
2540  * gtk_file_chooser_get_show_hidden:
2541  * @chooser: a #GtkFileChooser
2542  * 
2543  * Gets whether hidden files and folders are displayed in the file selector.   
2544  * See gtk_file_chooser_set_show_hidden().
2545  * 
2546  * Return value: %TRUE if hidden files and folders are displayed.
2547  *
2548  * Since: 2.6
2549  **/
2550 gboolean
2551 gtk_file_chooser_get_show_hidden (GtkFileChooser *chooser)
2552 {
2553   gboolean show_hidden;
2554   
2555   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2556
2557   g_object_get (chooser, "show-hidden", &show_hidden, NULL);
2558
2559   return show_hidden;
2560 }
2561
2562 /**
2563  * gtk_file_chooser_set_do_overwrite_confirmation:
2564  * @chooser: a #GtkFileChooser
2565  * @do_overwrite_confirmation: whether to confirm overwriting in save mode
2566  * 
2567  * Sets whether a file chooser in %GTK_FILE_CHOOSER_ACTION_SAVE mode will present
2568  * a confirmation dialog if the user types a file name that already exists.  This
2569  * is %FALSE by default.
2570  *
2571  * Regardless of this setting, the @chooser will emit the
2572  * #GtkFileChooser::confirm-overwrite signal when appropriate.
2573  *
2574  * If all you need is the stock confirmation dialog, set this property to %TRUE.
2575  * You can override the way confirmation is done by actually handling the
2576  * #GtkFileChooser::confirm-overwrite signal; please refer to its documentation
2577  * for the details.
2578  *
2579  * Since: 2.8
2580  **/
2581 void
2582 gtk_file_chooser_set_do_overwrite_confirmation (GtkFileChooser *chooser,
2583                                                 gboolean        do_overwrite_confirmation)
2584 {
2585   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
2586
2587   g_object_set (chooser, "do-overwrite-confirmation", do_overwrite_confirmation, NULL);
2588 }
2589
2590 /**
2591  * gtk_file_chooser_get_do_overwrite_confirmation:
2592  * @chooser: a #GtkFileChooser
2593  * 
2594  * Queries whether a file chooser is set to confirm for overwriting when the user
2595  * types a file name that already exists.
2596  * 
2597  * Return value: %TRUE if the file chooser will present a confirmation dialog;
2598  * %FALSE otherwise.
2599  *
2600  * Since: 2.8
2601  **/
2602 gboolean
2603 gtk_file_chooser_get_do_overwrite_confirmation (GtkFileChooser *chooser)
2604 {
2605   gboolean do_overwrite_confirmation;
2606
2607   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
2608
2609   g_object_get (chooser, "do-overwrite-confirmation", &do_overwrite_confirmation, NULL);
2610
2611   return do_overwrite_confirmation;
2612 }