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