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