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