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