]> Pileus Git - ~andy/gtk/blob - gtk/gtkfilechooser.c
e5e225b932da0780aaec219df4d9006f134f03df
[~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 "gtkfilesystem.h"
25 #include "gtkintl.h"
26 #include "gtktypebuiltins.h"
27 #include "gtkprivate.h"
28 #include "gtkmarshalers.h"
29 #include "gtkalias.h"
30
31 static void gtk_file_chooser_class_init (gpointer g_iface);
32
33 static GtkFilePath *gtk_file_chooser_get_path         (GtkFileChooser *chooser);
34
35 GType
36 gtk_file_chooser_get_type (void)
37 {
38   static GType file_chooser_type = 0;
39
40   if (!file_chooser_type)
41     {
42       file_chooser_type = g_type_register_static_simple (G_TYPE_INTERFACE,
43                                                          I_("GtkFileChooser"),
44                                                          sizeof (GtkFileChooserIface),
45                                                          (GClassInitFunc) gtk_file_chooser_class_init,
46                                                          0, NULL, 0);
47       
48       g_type_interface_add_prerequisite (file_chooser_type, GTK_TYPE_WIDGET);
49     }
50
51   return file_chooser_type;
52 }
53
54 static gboolean
55 confirm_overwrite_accumulator (GSignalInvocationHint *ihint,
56                                GValue                *return_accu,
57                                const GValue          *handler_return,
58                                gpointer               dummy)
59 {
60   gboolean continue_emission;
61   GtkFileChooserConfirmation conf;
62
63   conf = g_value_get_enum (handler_return);
64   g_value_set_enum (return_accu, conf);
65   continue_emission = (conf == GTK_FILE_CHOOSER_CONFIRMATION_CONFIRM);
66
67   return continue_emission;
68 }
69
70 static void
71 gtk_file_chooser_class_init (gpointer g_iface)
72 {
73   GType iface_type = G_TYPE_FROM_INTERFACE (g_iface);
74
75   /**
76    * GtkFileChooser::current-folder-changed
77    * @chooser: the object which received the signal.
78    *
79    * This signal is emitted when the current folder in a #GtkFileChooser
80    * changes.  This can happen due to the user performing some action that
81    * changes folders, such as selecting a bookmark or visiting a folder on the
82    * file list.  It can also happen as a result of calling a function to
83    * explicitly change the current folder in a file chooser.
84    *
85    * Normally you do not need to connect to this signal, unless you need to keep
86    * track of which folder a file chooser is showing.
87    *
88    * See also:  gtk_file_chooser_set_current_folder(),
89    * gtk_file_chooser_get_current_folder(),
90    * gtk_file_chooser_set_current_folder_uri(),
91    * gtk_file_chooser_get_current_folder_uri().
92    */
93   g_signal_new (I_("current-folder-changed"),
94                 iface_type,
95                 G_SIGNAL_RUN_LAST,
96                 G_STRUCT_OFFSET (GtkFileChooserIface, current_folder_changed),
97                 NULL, NULL,
98                 g_cclosure_marshal_VOID__VOID,
99                 G_TYPE_NONE, 0);
100
101   /**
102    * GtkFileChooser::selection-changed
103    * @chooser: the object which received the signal.
104    *
105    * This signal is emitted when there is a change in the set of selected files
106    * in a #GtkFileChooser.  This can happen when the user modifies the selection
107    * with the mouse or the keyboard, or when explicitly calling functions to
108    * change the selection.
109    *
110    * Normally you do not need to connect to this signal, as it is easier to wait
111    * for the file chooser to finish running, and then to get the list of
112    * selected files using the functions mentioned below.
113    *
114    * See also: gtk_file_chooser_select_filename(),
115    * gtk_file_chooser_unselect_filename(), gtk_file_chooser_get_filename(),
116    * gtk_file_chooser_get_filenames(), gtk_file_chooser_select_uri(),
117    * gtk_file_chooser_unselect_uri(), gtk_file_chooser_get_uri(),
118    * gtk_file_chooser_get_uris().
119    */
120   g_signal_new (I_("selection-changed"),
121                 iface_type,
122                 G_SIGNAL_RUN_LAST,
123                 G_STRUCT_OFFSET (GtkFileChooserIface, selection_changed),
124                 NULL, NULL,
125                 g_cclosure_marshal_VOID__VOID,
126                 G_TYPE_NONE, 0);
127
128   /**
129    * GtkFileChooser::update-preview
130    * @chooser: the object which received the signal.
131    *
132    * This signal is emitted when the preview in a file chooser should be
133    * regenerated.  For example, this can happen when the currently selected file
134    * changes.  You should use this signal if you want your file chooser to have
135    * a preview widget.
136    *
137    * Once you have installed a preview widget with
138    * gtk_file_chooser_set_preview_widget(), you should update it when this
139    * signal is emitted.  You can use the functions
140    * gtk_file_chooser_get_preview_filename() or
141    * gtk_file_chooser_get_preview_uri() to get the name of the file to preview.
142    * Your widget may not be able to preview all kinds of files; your callback
143    * must call gtk_file_chooser_set_preview_widget_active() to inform the file
144    * chooser about whether the preview was generated successfully or not.
145    *
146    * Please see the example code in <xref linkend="gtkfilechooser-preview"/>.
147    *
148    * See also: gtk_file_chooser_set_preview_widget(),
149    * gtk_file_chooser_set_preview_widget_active(),
150    * gtk_file_chooser_set_use_preview_label(),
151    * gtk_file_chooser_get_preview_filename(),
152    * gtk_file_chooser_get_preview_uri().
153    */
154   g_signal_new (I_("update-preview"),
155                 iface_type,
156                 G_SIGNAL_RUN_LAST,
157                 G_STRUCT_OFFSET (GtkFileChooserIface, update_preview),
158                 NULL, NULL,
159                 g_cclosure_marshal_VOID__VOID,
160                 G_TYPE_NONE, 0);
161
162   /**
163    * GtkFileChooser::file-activated
164    * @chooser: the object which received the signal.
165    *
166    * This signal is emitted when the user "activates" a file in the file
167    * chooser.  This can happen by double-clicking on a file in the file list, or
168    * by pressing <keycap>Enter</keycap>.
169    *
170    * Normally you do not need to connect to this signal.  It is used internally
171    * by #GtkFileChooserDialog to know when to activate the default button in the
172    * dialog.
173    *
174    * See also: gtk_file_chooser_get_filename(),
175    * gtk_file_chooser_get_filenames(), gtk_file_chooser_get_uri(),
176    * gtk_file_chooser_get_uris().
177    */
178   g_signal_new (I_("file-activated"),
179                 iface_type,
180                 G_SIGNAL_RUN_LAST,
181                 G_STRUCT_OFFSET (GtkFileChooserIface, file_activated),
182                 NULL, NULL,
183                 g_cclosure_marshal_VOID__VOID,
184                 G_TYPE_NONE, 0);
185
186   /* Documented in the docbook files */
187   g_signal_new (I_("confirm-overwrite"),
188                 iface_type,
189                 G_SIGNAL_RUN_LAST,
190                 G_STRUCT_OFFSET (GtkFileChooserIface, confirm_overwrite),
191                 confirm_overwrite_accumulator, NULL,
192                 _gtk_marshal_ENUM__VOID,
193                 GTK_TYPE_FILE_CHOOSER_CONFIRMATION, 0);
194   
195   g_object_interface_install_property (g_iface,
196                                        g_param_spec_enum ("action",
197                                                           P_("Action"),
198                                                           P_("The type of operation that the file selector is performing"),
199                                                           GTK_TYPE_FILE_CHOOSER_ACTION,
200                                                           GTK_FILE_CHOOSER_ACTION_OPEN,
201                                                           GTK_PARAM_READWRITE));
202   g_object_interface_install_property (g_iface,
203                                        g_param_spec_string ("file-system-backend",
204                                                             P_("File System Backend"),
205                                                             P_("Name of file system backend to use"),
206                                                             NULL, 
207                                                             GTK_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
208   g_object_interface_install_property (g_iface,
209                                        g_param_spec_object ("filter",
210                                                             P_("Filter"),
211                                                             P_("The current filter for selecting which files are displayed"),
212                                                             GTK_TYPE_FILE_FILTER,
213                                                             GTK_PARAM_READWRITE));
214   g_object_interface_install_property (g_iface,
215                                        g_param_spec_boolean ("local-only",
216                                                              P_("Local Only"),
217                                                              P_("Whether the selected file(s) should be limited to local file: URLs"),
218                                                              TRUE,
219                                                              GTK_PARAM_READWRITE));
220   g_object_interface_install_property (g_iface,
221                                        g_param_spec_object ("preview-widget",
222                                                             P_("Preview widget"),
223                                                             P_("Application supplied widget for custom previews."),
224                                                             GTK_TYPE_WIDGET,
225                                                             GTK_PARAM_READWRITE));
226   g_object_interface_install_property (g_iface,
227                                        g_param_spec_boolean ("preview-widget-active",
228                                                              P_("Preview Widget Active"),
229                                                              P_("Whether the application supplied widget for custom previews should be shown."),
230                                                              TRUE,
231                                                              GTK_PARAM_READWRITE));
232   g_object_interface_install_property (g_iface,
233                                        g_param_spec_boolean ("use-preview-label",
234                                                              P_("Use Preview Label"),
235                                                              P_("Whether to display a stock label with the name of the previewed file."),
236                                                              TRUE,
237                                                              GTK_PARAM_READWRITE));
238   g_object_interface_install_property (g_iface,
239                                        g_param_spec_object ("extra-widget",
240                                                             P_("Extra widget"),
241                                                             P_("Application supplied widget for extra options."),
242                                                             GTK_TYPE_WIDGET,
243                                                             GTK_PARAM_READWRITE));
244   g_object_interface_install_property (g_iface,
245                                        g_param_spec_boolean ("select-multiple",
246                                                              P_("Select Multiple"),
247                                                              P_("Whether to allow multiple files to be selected"),
248                                                              FALSE,
249                                                              GTK_PARAM_READWRITE));
250   
251   g_object_interface_install_property (g_iface,
252                                        g_param_spec_boolean ("show-hidden",
253                                                              P_("Show Hidden"),
254                                                              P_("Whether the hidden files and folders should be displayed"),
255                                                              FALSE,
256                                                              GTK_PARAM_READWRITE));
257
258   /**
259    * GtkFileChooser:do-overwrite-confirmation:
260    * 
261    * Whether a file chooser in %GTK_FILE_CHOOSER_ACTION_SAVE mode
262    * will present an overwrite confirmation dialog if the user
263    * selects a file name that already exists.
264    *
265    * Since: 2.8
266    */
267   g_object_interface_install_property (g_iface,
268                                        g_param_spec_boolean ("do-overwrite-confirmation",
269                                                              P_("Do overwrite confirmation"),
270                                                              P_("Whether a file chooser in save mode "
271                                                                 "will present an overwrite confirmation dialog "
272                                                                 "if necessary."),
273                                                              FALSE,
274                                                              GTK_PARAM_READWRITE));
275 }
276
277 /**
278  * gtk_file_chooser_error_quark:
279  *
280  * Registers an error quark for #GtkFileChooser if necessary.
281  * 
282  * Return value: The error quark used for #GtkFileChooser errors.
283  *
284  * Since: 2.4
285  **/
286 GQuark
287 gtk_file_chooser_error_quark (void)
288 {
289   return g_quark_from_static_string ("gtk-file-chooser-error-quark");
290 }
291
292 /**
293  * gtk_file_chooser_set_action:
294  * @chooser: a #GtkFileChooser
295  * @action: the action that the file selector is performing
296  * 
297  * Sets the type of operation that the chooser is performing; the
298  * user interface is adapted to suit the selected action. For example,
299  * an option to create a new folder might be shown if the action is
300  * %GTK_FILE_CHOOSER_ACTION_SAVE but not if the action is
301  * %GTK_FILE_CHOOSER_ACTION_OPEN.
302  *
303  * Since: 2.4
304  **/
305 void
306 gtk_file_chooser_set_action (GtkFileChooser       *chooser,
307                              GtkFileChooserAction  action)
308 {
309   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
310
311   g_object_set (chooser, "action", action, NULL);
312 }
313
314 /**
315  * gtk_file_chooser_get_action:
316  * @chooser: a #GtkFileChooser
317  * 
318  * Gets the type of operation that the file chooser is performing; see
319  * gtk_file_chooser_set_action().
320  * 
321  * Return value: the action that the file selector is performing
322  *
323  * Since: 2.4
324  **/
325 GtkFileChooserAction
326 gtk_file_chooser_get_action (GtkFileChooser *chooser)
327 {
328   GtkFileChooserAction action;
329   
330   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
331
332   g_object_get (chooser, "action", &action, NULL);
333
334   return action;
335 }
336
337 /**
338  * gtk_file_chooser_set_local_only:
339  * @chooser: a #GtkFileChooser
340  * @local_only: %TRUE if only local files can be selected
341  * 
342  * Sets whether only local files can be selected in the
343  * file selector. If @local_only is %TRUE (the default),
344  * then the selected file are files are guaranteed to be
345  * accessible through the operating systems native file
346  * file system and therefore the application only
347  * needs to worry about the filename functions in
348  * #GtkFileChooser, like gtk_file_chooser_get_filename(),
349  * rather than the URI functions like
350  * gtk_file_chooser_get_uri(),
351  *
352  * Since: 2.4
353  **/
354 void
355 gtk_file_chooser_set_local_only (GtkFileChooser *chooser,
356                                  gboolean        local_only)
357 {
358   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
359
360   g_object_set (chooser, "local-only", local_only, NULL);
361 }
362
363 /**
364  * gtk_file_chooser_get_local_only:
365  * @chooser: a #GtkFileChoosre
366  * 
367  * Gets whether only local files can be selected in the
368  * file selector. See gtk_file_chooser_set_local_only()
369  * 
370  * Return value: %TRUE if only local files can be selected.
371  *
372  * Since: 2.4
373  **/
374 gboolean
375 gtk_file_chooser_get_local_only (GtkFileChooser *chooser)
376 {
377   gboolean local_only;
378   
379   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
380
381   g_object_get (chooser, "local-only", &local_only, NULL);
382
383   return local_only;
384 }
385
386 /**
387  * gtk_file_chooser_set_select_multiple:
388  * @chooser: a #GtkFileChooser
389  * @select_multiple: %TRUE if multiple files can be selected.
390  * 
391  * Sets whether multiple files can be selected in the file selector.  This is
392  * only relevant if the action is set to be GTK_FILE_CHOOSER_ACTION_OPEN or
393  * GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER.  
394  *
395  * Since: 2.4
396  **/
397 void
398 gtk_file_chooser_set_select_multiple (GtkFileChooser *chooser,
399                                       gboolean        select_multiple)
400 {
401   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
402
403   g_object_set (chooser, "select-multiple", select_multiple, NULL);
404 }
405
406 /**
407  * gtk_file_chooser_get_select_multiple:
408  * @chooser: a #GtkFileChooser
409  * 
410  * Gets whether multiple files can be selected in the file
411  * selector. See gtk_file_chooser_set_select_multiple().
412  * 
413  * Return value: %TRUE if multiple files can be selected.
414  *
415  * Since: 2.4
416  **/
417 gboolean
418 gtk_file_chooser_get_select_multiple (GtkFileChooser *chooser)
419 {
420   gboolean select_multiple;
421   
422   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
423
424   g_object_get (chooser, "select-multiple", &select_multiple, NULL);
425
426   return select_multiple;
427 }
428
429 /**
430  * gtk_file_chooser_get_filename:
431  * @chooser: a #GtkFileChooser
432  * 
433  * Gets the filename for the currently selected file in
434  * the file selector. If multiple files are selected,
435  * one of the filenames will be returned at random.
436  *
437  * If the file chooser is in folder mode, this function returns the selected
438  * folder.
439  * 
440  * Return value: The currently selected filename, or %NULL
441  *  if no file is selected, or the selected file can't
442  *  be represented with a local filename. Free with g_free().
443  *
444  * Since: 2.4
445  **/
446 gchar *
447 gtk_file_chooser_get_filename (GtkFileChooser *chooser)
448 {
449   GtkFileSystem *file_system;
450   GtkFilePath *path;
451   gchar *result = NULL;
452   
453   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
454
455   file_system = _gtk_file_chooser_get_file_system (chooser);
456   path = gtk_file_chooser_get_path (chooser);
457   if (path)
458     {
459       result = gtk_file_system_path_to_filename (file_system, path);
460       gtk_file_path_free (path);
461     }
462
463   return result;
464 }
465
466 /**
467  * gtk_file_chooser_set_filename:
468  * @chooser: a #GtkFileChooser
469  * @filename: the filename to set as current
470  * 
471  * Sets @filename as the current filename for the file chooser, by changing
472  * to the file's parent folder and actually selecting the file in list.  If
473  * the @chooser is in #GTK_FILE_CHOOSER_ACTION_SAVE mode, the file's base name
474  * will also appear in the dialog's file name entry.
475  *
476  * If the file name isn't in the current folder of @chooser, then the current
477  * folder of @chooser will be changed to the folder containing @filename. This
478  * is equivalent to a sequence of gtk_file_chooser_unselect_all() followed by
479  * gtk_file_chooser_select_filename().
480  *
481  * Note that the file must exist, or nothing will be done except
482  * for the directory change.
483  *
484  * If you are implementing a <guimenuitem>File/Save As...</guimenuitem> dialog,
485  * you should use this function if you already have a file name to which the 
486  * user may save; for example, when the user opens an existing file and then 
487  * does <guimenuitem>File/Save As...</guimenuitem> on it.  If you don't have 
488  * a file name already &mdash; for example, if the user just created a new 
489  * file and is saving it for the first time, do not call this function.  
490  * Instead, use something similar to this:
491  * |[
492  * if (document_is_new)
493  *   {
494  *     /&ast; the user just created a new document &ast;/
495  *     gtk_file_chooser_set_current_folder (chooser, default_folder_for_saving);
496  *     gtk_file_chooser_set_current_name (chooser, "Untitled document");
497  *   }
498  * else
499  *   {
500  *     /&ast; the user edited an existing document &ast;/ 
501  *     gtk_file_chooser_set_filename (chooser, existing_filename);
502  *   }
503  * ]|
504  * 
505  * Return value: %TRUE if both the folder could be changed and the file was
506  * selected successfully, %FALSE otherwise.
507  *
508  * Since: 2.4
509  **/
510 gboolean
511 gtk_file_chooser_set_filename (GtkFileChooser *chooser,
512                                const gchar    *filename)
513 {
514   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
515
516   gtk_file_chooser_unselect_all (chooser);
517   return gtk_file_chooser_select_filename (chooser, filename);
518 }
519
520 /**
521  * gtk_file_chooser_select_filename:
522  * @chooser: a #GtkFileChooser
523  * @filename: the filename to select
524  * 
525  * Selects a filename. If the file name isn't in the current
526  * folder of @chooser, then the current folder of @chooser will
527  * be changed to the folder containing @filename.
528  *
529  * Return value: %TRUE if both the folder could be changed and the file was
530  * selected successfully, %FALSE otherwise.
531  *
532  * Since: 2.4
533  **/
534 gboolean
535 gtk_file_chooser_select_filename (GtkFileChooser *chooser,
536                                   const gchar    *filename)
537 {
538   GtkFileSystem *file_system;
539   GtkFilePath *path;
540   gboolean result;
541   
542   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
543   g_return_val_if_fail (filename != NULL, FALSE);
544
545   file_system = _gtk_file_chooser_get_file_system (chooser);
546
547   path = gtk_file_system_filename_to_path (file_system, filename);
548   if (path)
549     {
550       result = _gtk_file_chooser_select_path (chooser, path, NULL);
551       gtk_file_path_free (path);
552     }
553   else
554     result = FALSE;
555
556   return result;
557 }
558
559 /**
560  * gtk_file_chooser_unselect_filename:
561  * @chooser: a #GtkFileChooser
562  * @filename: the filename to unselect
563  * 
564  * Unselects a currently selected filename. If the filename
565  * is not in the current directory, does not exist, or
566  * is otherwise not currently selected, does nothing.
567  *
568  * Since: 2.4
569  **/
570 void
571 gtk_file_chooser_unselect_filename (GtkFileChooser *chooser,
572                                     const char     *filename)
573 {
574   GtkFileSystem *file_system;
575   GtkFilePath *path;
576   
577   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
578   g_return_if_fail (filename != NULL);
579
580   file_system = _gtk_file_chooser_get_file_system (chooser);
581
582   path = gtk_file_system_filename_to_path (file_system, filename);
583   if (path)
584     {
585       _gtk_file_chooser_unselect_path (chooser, path);
586       gtk_file_path_free (path);
587     }
588 }
589
590 /* Converts a list of GtkFilePath* to a list of strings using the specified function */
591 static GSList *
592 file_paths_to_strings (GtkFileSystem *fs,
593                        GSList        *paths,
594                        gchar *      (*convert_func) (GtkFileSystem *fs, const GtkFilePath *path))
595 {
596   GSList *strings;
597
598   strings = NULL;
599
600   for (; paths; paths = paths->next)
601     {
602       GtkFilePath *path;
603       gchar *string;
604
605       path = paths->data;
606       string = (* convert_func) (fs, path);
607
608       if (string)
609         strings = g_slist_prepend (strings, string);
610     }
611
612   return g_slist_reverse (strings);
613 }
614
615 /**
616  * gtk_file_chooser_get_filenames:
617  * @chooser: a #GtkFileChooser
618  * 
619  * Lists all the selected files and subfolders in the current folder of
620  * @chooser. The returned names are full absolute paths. If files in the current
621  * folder cannot be represented as local filenames they will be ignored. (See
622  * gtk_file_chooser_get_uris())
623  * 
624  * Return value: a #GSList containing the filenames of all selected
625  *   files and subfolders in the current folder. Free the returned list
626  *   with g_slist_free(), and the filenames with g_free().
627  *
628  * Since: 2.4
629  **/
630 GSList *
631 gtk_file_chooser_get_filenames (GtkFileChooser *chooser)
632 {
633   GtkFileSystem *file_system;
634   GSList *paths;
635   GSList *result;
636   
637   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
638
639   file_system = _gtk_file_chooser_get_file_system (chooser);
640   paths = _gtk_file_chooser_get_paths (chooser);
641
642   result = file_paths_to_strings (file_system, paths, gtk_file_system_path_to_filename);
643   gtk_file_paths_free (paths);
644   return result;
645 }
646
647 /**
648  * gtk_file_chooser_set_current_folder:
649  * @chooser: a #GtkFileChooser
650  * @filename: the full path of the new current folder
651  * 
652  * Sets the current folder for @chooser from a local filename.
653  * The user will be shown the full contents of the current folder,
654  * plus user interface elements for navigating to other folders.
655  *
656  * Return value: %TRUE if the folder could be changed successfully, %FALSE
657  * otherwise.
658  *
659  * Since: 2.4
660  **/
661 gboolean
662 gtk_file_chooser_set_current_folder (GtkFileChooser *chooser,
663                                      const gchar    *filename)
664 {
665   GtkFileSystem *file_system;
666   GtkFilePath *path;
667   gboolean result;
668   
669   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
670   g_return_val_if_fail (filename != NULL, FALSE);
671
672   file_system = _gtk_file_chooser_get_file_system (chooser);
673
674   path = gtk_file_system_filename_to_path (file_system, filename);
675   if (path)
676     {
677       result = _gtk_file_chooser_set_current_folder_path (chooser, path, NULL);
678       gtk_file_path_free (path);
679     }
680   else
681     result = FALSE;
682
683   return result;
684 }
685
686 /**
687  * gtk_file_chooser_get_current_folder:
688  * @chooser: a #GtkFileChooser
689  * 
690  * Gets the current folder of @chooser as a local filename.
691  * See gtk_file_chooser_set_current_folder().
692  *
693  * Note that this is the folder that the file chooser is currently displaying
694  * (e.g. "/home/username/Documents"), which is <emphasis>not the same</emphasis>
695  * as the currently-selected folder if the chooser is in
696  * #GTK_FILE_CHOOSER_SELECT_FOLDER mode
697  * (e.g. "/home/username/Documents/selected-folder/".  To get the
698  * currently-selected folder in that mode, use gtk_file_chooser_get_uri() as the
699  * usual way to get the selection.
700  * 
701  * Return value: the full path of the current folder, or %NULL if the current
702  * path cannot be represented as a local filename.  Free with g_free().  This
703  * function will also return %NULL if the file chooser was unable to load the
704  * last folder that was requested from it; for example, as would be for calling
705  * gtk_file_chooser_set_current_folder() on a nonexistent folder.
706  *
707  * Since: 2.4
708  **/
709 gchar *
710 gtk_file_chooser_get_current_folder (GtkFileChooser *chooser)
711 {
712   GtkFileSystem *file_system;
713   GtkFilePath *path;
714   gchar *filename;
715   
716   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
717
718   file_system = _gtk_file_chooser_get_file_system (chooser);
719
720   path = _gtk_file_chooser_get_current_folder_path (chooser);
721   if (!path)
722     return NULL;
723
724   filename = gtk_file_system_path_to_filename (file_system, path);
725   gtk_file_path_free (path);
726
727   return filename;
728 }
729
730 /**
731  * gtk_file_chooser_set_current_name:
732  * @chooser: a #GtkFileChooser
733  * @name: the filename to use, as a UTF-8 string
734  * 
735  * Sets the current name in the file selector, as if entered
736  * by the user. Note that the name passed in here is a UTF-8
737  * string rather than a filename. This function is meant for
738  * such uses as a suggested name in a "Save As..." dialog.
739  *
740  * If you want to preselect a particular existing file, you should use
741  * gtk_file_chooser_set_filename() or gtk_file_chooser_set_uri() instead.
742  * Please see the documentation for those functions for an example of using
743  * gtk_file_chooser_set_current_name() as well.
744  *
745  * Since: 2.4
746  **/
747 void
748 gtk_file_chooser_set_current_name  (GtkFileChooser *chooser,
749                                     const gchar    *name)
750 {
751   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
752   g_return_if_fail (name != NULL);
753   
754   GTK_FILE_CHOOSER_GET_IFACE (chooser)->set_current_name (chooser, name);
755 }
756
757 /**
758  * gtk_file_chooser_get_uri:
759  * @chooser: a #GtkFileChooser
760  * 
761  * Gets the URI for the currently selected file in
762  * the file selector. If multiple files are selected,
763  * one of the filenames will be returned at random.
764  * 
765  * If the file chooser is in folder mode, this function returns the selected
766  * folder.
767  * 
768  * Return value: The currently selected URI, or %NULL
769  *  if no file is selected. Free with g_free()
770  *
771  * Since: 2.4
772  **/
773 gchar *
774 gtk_file_chooser_get_uri (GtkFileChooser *chooser)
775 {
776   GtkFileSystem *file_system;
777   GtkFilePath *path;
778   gchar *result = NULL;
779   
780   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
781
782   file_system = _gtk_file_chooser_get_file_system (chooser);
783   path = gtk_file_chooser_get_path (chooser);
784   if (path)
785     {
786       result = gtk_file_system_path_to_uri (file_system, path);
787       gtk_file_path_free (path);
788     }
789
790   return result;
791 }
792
793 /**
794  * gtk_file_chooser_set_uri:
795  * @chooser: a #GtkFileChooser
796  * @uri: the URI to set as current
797  * 
798  * Sets the file referred to by @uri as the current file for the file chooser,
799  * by changing to the URI's parent folder and actually selecting the URI in the
800  * list.  If the @chooser is #GTK_FILE_CHOOSER_ACTION_SAVE mode, the URI's base
801  * name will also appear in the dialog's file name entry.
802  *
803  * If the URI isn't in the current folder of @chooser, then the current folder
804  * of @chooser will be changed to the folder containing @uri. This is equivalent
805  * to a sequence of gtk_file_chooser_unselect_all() followed by
806  * gtk_file_chooser_select_uri().
807  *
808  * Note that the URI must exist, or nothing will be done except for the 
809  * directory change.
810  * If you are implementing a <guimenuitem>File/Save As...</guimenuitem> dialog,
811  * you should use this function if you already have a file name to which the 
812  * user may save; for example, when the user opens an existing file and then 
813  * does <guimenuitem>File/Save As...</guimenuitem> on it.  If you don't have 
814  * a file name already &mdash; for example, if the user just created a new 
815  * file and is saving it for the first time, do not call this function.  
816  * Instead, use something similar to this:
817  * |[
818  * if (document_is_new)
819  *   {
820  *     /&ast; the user just created a new document &ast;/
821  *     gtk_file_chooser_set_current_folder_uri (chooser, default_folder_for_saving);
822  *     gtk_file_chooser_set_current_name (chooser, "Untitled document");
823  *   }
824  * else
825  *   {
826  *     /&ast; the user edited an existing document &ast;/ 
827  *     gtk_file_chooser_set_uri (chooser, existing_uri);
828  *   }
829  * ]|
830  *
831  * Return value: %TRUE if both the folder could be changed and the URI was
832  * selected successfully, %FALSE otherwise.
833  *
834  * Since: 2.4
835  **/
836 gboolean
837 gtk_file_chooser_set_uri (GtkFileChooser *chooser,
838                           const char     *uri)
839 {
840   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
841
842   gtk_file_chooser_unselect_all (chooser);
843   return gtk_file_chooser_select_uri (chooser, uri);
844 }
845
846 /**
847  * gtk_file_chooser_select_uri:
848  * @chooser: a #GtkFileChooser
849  * @uri: the URI to select
850  * 
851  * Selects the file to by @uri. If the URI doesn't refer to a
852  * file in the current folder of @chooser, then the current folder of
853  * @chooser will be changed to the folder containing @filename.
854  *
855  * Return value: %TRUE if both the folder could be changed and the URI was
856  * selected successfully, %FALSE otherwise.
857  *
858  * Since: 2.4
859  **/
860 gboolean
861 gtk_file_chooser_select_uri (GtkFileChooser *chooser,
862                              const char     *uri)
863 {
864   GtkFileSystem *file_system;
865   GtkFilePath *path;
866   gboolean result;
867   
868   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
869   g_return_val_if_fail (uri != NULL, FALSE);
870
871   file_system = _gtk_file_chooser_get_file_system (chooser);
872
873   path = gtk_file_system_uri_to_path (file_system, uri);
874   if (path)
875     {
876       result = _gtk_file_chooser_select_path (chooser, path, NULL);
877       gtk_file_path_free (path);
878     }
879   else
880     result = FALSE;
881
882   return result;
883 }
884
885 /**
886  * gtk_file_chooser_unselect_uri:
887  * @chooser: a #GtkFileChooser
888  * @uri: the URI to unselect
889  * 
890  * Unselects the file referred to by @uri. If the file
891  * is not in the current directory, does not exist, or
892  * is otherwise not currently selected, does nothing.
893  *
894  * Since: 2.4
895  **/
896 void
897 gtk_file_chooser_unselect_uri (GtkFileChooser *chooser,
898                                const char     *uri)
899 {
900   GtkFileSystem *file_system;
901   GtkFilePath *path;
902   
903   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
904   g_return_if_fail (uri != NULL);
905
906   file_system = _gtk_file_chooser_get_file_system (chooser);
907
908   path = gtk_file_system_uri_to_path (file_system, uri);
909   if (path)
910     {
911       _gtk_file_chooser_unselect_path (chooser, path);
912       gtk_file_path_free (path);
913     }
914 }
915
916 /**
917  * gtk_file_chooser_select_all:
918  * @chooser: a #GtkFileChooser
919  * 
920  * Selects all the files in the current folder of a file chooser.
921  *
922  * Since: 2.4
923  **/
924 void
925 gtk_file_chooser_select_all (GtkFileChooser *chooser)
926 {
927   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
928   
929   GTK_FILE_CHOOSER_GET_IFACE (chooser)->select_all (chooser);
930 }
931
932 /**
933  * gtk_file_chooser_unselect_all:
934  * @chooser: a #GtkFileChooser
935  * 
936  * Unselects all the files in the current folder of a file chooser.
937  *
938  * Since: 2.4
939  **/
940 void
941 gtk_file_chooser_unselect_all (GtkFileChooser *chooser)
942 {
943
944   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
945   
946   GTK_FILE_CHOOSER_GET_IFACE (chooser)->unselect_all (chooser);
947 }
948
949 /**
950  * gtk_file_chooser_get_uris:
951  * @chooser: a #GtkFileChooser
952  * 
953  * Lists all the selected files and subfolders in the current folder of
954  * @chooser. The returned names are full absolute URIs.
955  * 
956  * Return value: a #GSList containing the URIs of all selected
957  *   files and subfolders in the current folder. Free the returned list
958  *   with g_slist_free(), and the filenames with g_free().
959  *
960  * Since: 2.4
961  **/
962 GSList *
963 gtk_file_chooser_get_uris (GtkFileChooser *chooser)
964 {
965   GtkFileSystem *file_system;
966   GSList *paths;
967   GSList *result;
968   
969   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
970
971   file_system = _gtk_file_chooser_get_file_system (chooser);
972   paths = _gtk_file_chooser_get_paths (chooser);
973
974   result = file_paths_to_strings (file_system, paths, gtk_file_system_path_to_uri);
975   gtk_file_paths_free (paths);
976   return result;
977 }
978
979 /**
980  * gtk_file_chooser_set_current_folder_uri:
981  * @chooser: a #GtkFileChooser
982  * @uri: the URI for the new current folder
983  * 
984  * Sets the current folder for @chooser from an URI.
985  * The user will be shown the full contents of the current folder,
986  * plus user interface elements for navigating to other folders.
987  *
988  * Return value: %TRUE if the folder could be changed successfully, %FALSE
989  * otherwise.
990  *
991  * Since: 2.4
992  **/
993 gboolean
994 gtk_file_chooser_set_current_folder_uri (GtkFileChooser *chooser,
995                                          const gchar    *uri)
996 {
997   GtkFileSystem *file_system;
998   GtkFilePath *path;
999   gboolean result;
1000   
1001   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1002   g_return_val_if_fail (uri != NULL, FALSE);
1003
1004   file_system = _gtk_file_chooser_get_file_system (chooser);
1005
1006   path = gtk_file_system_uri_to_path (file_system, uri);
1007   if (path)
1008     {
1009       result = _gtk_file_chooser_set_current_folder_path (chooser, path, NULL);
1010       gtk_file_path_free (path);
1011     }
1012   else
1013     result = FALSE;
1014
1015   return result;
1016 }
1017
1018 /**
1019  * gtk_file_chooser_get_current_folder_uri:
1020  * @chooser: a #GtkFileChooser
1021  * 
1022  * Gets the current folder of @chooser as an URI.
1023  * See gtk_file_chooser_set_current_folder_uri().
1024  *
1025  * Note that this is the folder that the file chooser is currently displaying
1026  * (e.g. "file:///home/username/Documents"), which is <emphasis>not the same</emphasis>
1027  * as the currently-selected folder if the chooser is in
1028  * #GTK_FILE_CHOOSER_SELECT_FOLDER mode
1029  * (e.g. "file:///home/username/Documents/selected-folder/".  To get the
1030  * currently-selected folder in that mode, use gtk_file_chooser_get_uri() as the
1031  * usual way to get the selection.
1032  * 
1033  * Return value: the URI for the current folder.  Free with g_free().  This
1034  * function will also return %NULL if the file chooser was unable to load the
1035  * last folder that was requested from it; for example, as would be for calling
1036  * gtk_file_chooser_set_current_folder_uri() on a nonexistent folder.
1037  *
1038  * Since: 2.4
1039  */
1040 gchar *
1041 gtk_file_chooser_get_current_folder_uri (GtkFileChooser *chooser)
1042 {
1043   GtkFileSystem *file_system;
1044   GtkFilePath *path;
1045   gchar *uri;
1046   
1047   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1048
1049   file_system = _gtk_file_chooser_get_file_system (chooser);
1050
1051   path = _gtk_file_chooser_get_current_folder_path (chooser);
1052   if (!path)
1053     return NULL;
1054
1055   uri = gtk_file_system_path_to_uri (file_system, path);
1056   gtk_file_path_free (path);
1057
1058   return uri;
1059 }
1060
1061 /**
1062  * _gtk_file_chooser_set_current_folder_path:
1063  * @chooser: a #GtkFileChooser
1064  * @path: the #GtkFilePath for the new folder
1065  * @error: location to store error, or %NULL.
1066  * 
1067  * Sets the current folder for @chooser from a #GtkFilePath.
1068  * Internal function, see gtk_file_chooser_set_current_folder_uri().
1069  *
1070  * Return value: %TRUE if the folder could be changed successfully, %FALSE
1071  * otherwise.
1072  *
1073  * Since: 2.4
1074  **/
1075 gboolean
1076 _gtk_file_chooser_set_current_folder_path (GtkFileChooser    *chooser,
1077                                            const GtkFilePath *path,
1078                                            GError           **error)
1079 {
1080   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1081   g_return_val_if_fail (path != NULL, FALSE);
1082   g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
1083
1084   return GTK_FILE_CHOOSER_GET_IFACE (chooser)->set_current_folder (chooser, path, error);
1085 }
1086
1087 /**
1088  * _gtk_file_chooser_get_current_folder_path:
1089  * @chooser: a #GtkFileChooser
1090  * 
1091  * Gets the current folder of @chooser as #GtkFilePath.
1092  * See gtk_file_chooser_get_current_folder_uri().
1093  * 
1094  * Return value: the #GtkFilePath for the current folder.
1095  * Free with gtk_file_path_free().
1096  *
1097  * Since: 2.4
1098  */
1099 GtkFilePath *
1100 _gtk_file_chooser_get_current_folder_path (GtkFileChooser *chooser)
1101 {
1102   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1103
1104   return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_current_folder (chooser);  
1105 }
1106
1107 /**
1108  * _gtk_file_chooser_select_path:
1109  * @chooser: a #GtkFileChooser
1110  * @path: the path to select
1111  * @error: location to store error, or %NULL
1112  * 
1113  * Selects the file referred to by @path. An internal function. See
1114  * _gtk_file_chooser_select_uri().
1115  *
1116  * Return value: %TRUE if both the folder could be changed and the path was
1117  * selected successfully, %FALSE otherwise.
1118  *
1119  * Since: 2.4
1120  **/
1121 gboolean
1122 _gtk_file_chooser_select_path (GtkFileChooser    *chooser,
1123                                const GtkFilePath *path,
1124                                GError           **error)
1125 {
1126   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1127   g_return_val_if_fail (path != NULL, FALSE);
1128   g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
1129
1130   return GTK_FILE_CHOOSER_GET_IFACE (chooser)->select_path (chooser, path, error);
1131 }
1132
1133 /**
1134  * _gtk_file_chooser_unselect_path:
1135  * @chooser: a #GtkFileChooser
1136  * @path: the filename to path
1137  * 
1138  * Unselects the file referred to by @path. An internal
1139  * function. See _gtk_file_chooser_unselect_uri().
1140  *
1141  * Since: 2.4
1142  **/
1143 void
1144 _gtk_file_chooser_unselect_path (GtkFileChooser    *chooser,
1145                                  const GtkFilePath *path)
1146 {
1147   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1148
1149   GTK_FILE_CHOOSER_GET_IFACE (chooser)->unselect_path (chooser, path);
1150 }
1151
1152 /**
1153  * _gtk_file_chooser_get_paths:
1154  * @chooser: a #GtkFileChooser
1155  * 
1156  * Lists all the selected files and subfolders in the current folder of @chooser
1157  * as #GtkFilePath. An internal function, see gtk_file_chooser_get_uris().
1158  * 
1159  * Return value: a #GSList containing a #GtkFilePath for each selected
1160  *   file and subfolder in the current folder.  Free the returned list
1161  *   with g_slist_free(), and the paths with gtk_file_path_free().
1162  *
1163  * Since: 2.4
1164  **/
1165 GSList *
1166 _gtk_file_chooser_get_paths (GtkFileChooser *chooser)
1167 {
1168   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1169
1170   return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_paths (chooser);
1171 }
1172
1173 static GtkFilePath *
1174 gtk_file_chooser_get_path (GtkFileChooser *chooser)
1175 {
1176   GSList *list;
1177   GtkFilePath *result = NULL;
1178   
1179   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1180
1181   list = _gtk_file_chooser_get_paths (chooser);
1182   if (list)
1183     {
1184       result = list->data;
1185       list = g_slist_delete_link (list, list);
1186       gtk_file_paths_free (list);
1187     }
1188
1189   return result;
1190 }
1191
1192 /**
1193  * _gtk_file_chooser_get_file_system:
1194  * @chooser: a #GtkFileChooser
1195  * 
1196  * Gets the #GtkFileSystem of @chooser; this is an internal
1197  * implementation detail, used for conversion between paths
1198  * and filenames and URIs.
1199  * 
1200  * Return value: the file system for @chooser.
1201  *
1202  * Since: 2.4
1203  **/
1204 GtkFileSystem *
1205 _gtk_file_chooser_get_file_system (GtkFileChooser *chooser)
1206 {
1207   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1208
1209   return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_file_system (chooser);
1210 }
1211
1212 /* Preview widget
1213  */
1214 /**
1215  * gtk_file_chooser_set_preview_widget:
1216  * @chooser: a #GtkFileChooser
1217  * @preview_widget: widget for displaying preview.
1218  *
1219  * Sets an application-supplied widget to use to display a custom preview
1220  * of the currently selected file. To implement a preview, after setting the
1221  * preview widget, you connect to the ::update-preview
1222  * signal, and call gtk_file_chooser_get_preview_filename() or
1223  * gtk_file_chooser_get_preview_uri() on each change. If you can
1224  * display a preview of the new file, update your widget and
1225  * set the preview active using gtk_file_chooser_set_preview_widget_active().
1226  * Otherwise, set the preview inactive.
1227  *
1228  * When there is no application-supplied preview widget, or the
1229  * application-supplied preview widget is not active, the file chooser
1230  * may display an internally generated preview of the current file or
1231  * it may display no preview at all.
1232  *
1233  * Since: 2.4
1234  **/
1235 void
1236 gtk_file_chooser_set_preview_widget (GtkFileChooser *chooser,
1237                                      GtkWidget      *preview_widget)
1238 {
1239   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1240
1241   g_object_set (chooser, "preview-widget", preview_widget, NULL);
1242 }
1243
1244 /**
1245  * gtk_file_chooser_get_preview_widget:
1246  * @chooser: a #GtkFileChooser
1247  * 
1248  * Gets the current preview widget; see
1249  * gtk_file_chooser_set_preview_widget().
1250  * 
1251  * Return value: the current preview widget, or %NULL
1252  *
1253  * Since: 2.4
1254  **/
1255 GtkWidget *
1256 gtk_file_chooser_get_preview_widget (GtkFileChooser *chooser)
1257 {
1258   GtkWidget *preview_widget;
1259   
1260   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1261
1262   g_object_get (chooser, "preview-widget", &preview_widget, NULL);
1263   
1264   /* Horrid hack; g_object_get() refs returned objects but
1265    * that contradicts the memory management conventions
1266    * for accessors.
1267    */
1268   if (preview_widget)
1269     g_object_unref (preview_widget);
1270
1271   return preview_widget;
1272 }
1273
1274 /**
1275  * gtk_file_chooser_set_preview_widget_active:
1276  * @chooser: a #GtkFileChooser
1277  * @active: whether to display the user-specified preview widget
1278  * 
1279  * Sets whether the preview widget set by
1280  * gtk_file_chooser_set_preview_widget() should be shown for the
1281  * current filename. When @active is set to false, the file chooser
1282  * may display an internally generated preview of the current file
1283  * or it may display no preview at all. See
1284  * gtk_file_chooser_set_preview_widget() for more details.
1285  *
1286  * Since: 2.4
1287  **/
1288 void
1289 gtk_file_chooser_set_preview_widget_active (GtkFileChooser *chooser,
1290                                             gboolean        active)
1291 {
1292   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1293   
1294   g_object_set (chooser, "preview-widget-active", active, NULL);
1295 }
1296
1297 /**
1298  * gtk_file_chooser_get_preview_widget_active:
1299  * @chooser: a #GtkFileChooser
1300  * 
1301  * Gets whether the preview widget set by gtk_file_chooser_set_preview_widget()
1302  * should be shown for the current filename. See
1303  * gtk_file_chooser_set_preview_widget_active().
1304  * 
1305  * Return value: %TRUE if the preview widget is active for the current filename.
1306  *
1307  * Since: 2.4
1308  **/
1309 gboolean
1310 gtk_file_chooser_get_preview_widget_active (GtkFileChooser *chooser)
1311 {
1312   gboolean active;
1313   
1314   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1315
1316   g_object_get (chooser, "preview-widget-active", &active, NULL);
1317
1318   return active;
1319 }
1320
1321 /**
1322  * gtk_file_chooser_set_use_preview_label:
1323  * @chooser: a #GtkFileChooser
1324  * @use_label: whether to display a stock label with the name of the previewed file
1325  * 
1326  * Sets whether the file chooser should display a stock label with the name of
1327  * the file that is being previewed; the default is %TRUE.  Applications that
1328  * want to draw the whole preview area themselves should set this to %FALSE and
1329  * display the name themselves in their preview widget.
1330  *
1331  * See also: gtk_file_chooser_set_preview_widget()
1332  *
1333  * Since: 2.4
1334  **/
1335 void
1336 gtk_file_chooser_set_use_preview_label (GtkFileChooser *chooser,
1337                                         gboolean        use_label)
1338 {
1339   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1340
1341   g_object_set (chooser, "use-preview-label", use_label, NULL);
1342 }
1343
1344 /**
1345  * gtk_file_chooser_get_use_preview_label:
1346  * @chooser: a #GtkFileChooser
1347  * 
1348  * Gets whether a stock label should be drawn with the name of the previewed
1349  * file.  See gtk_file_chooser_set_use_preview_label().
1350  * 
1351  * Return value: %TRUE if the file chooser is set to display a label with the
1352  * name of the previewed file, %FALSE otherwise.
1353  **/
1354 gboolean
1355 gtk_file_chooser_get_use_preview_label (GtkFileChooser *chooser)
1356 {
1357   gboolean use_label;
1358   
1359   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1360
1361   g_object_get (chooser, "use-preview-label", &use_label, NULL);
1362
1363   return use_label;
1364 }
1365
1366 /**
1367  * gtk_file_chooser_get_preview_filename:
1368  * @chooser: a #GtkFileChooser
1369  * 
1370  * Gets the filename that should be previewed in a custom preview
1371  * Internal function, see gtk_file_chooser_get_preview_uri().
1372  * 
1373  * Return value: the #GtkFilePath for the file to preview, or %NULL if no file
1374  *  is selected. Free with gtk_file_path_free().
1375  *
1376  * Since: 2.4
1377  **/
1378 GtkFilePath *
1379 _gtk_file_chooser_get_preview_path (GtkFileChooser *chooser)
1380 {
1381   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1382
1383   return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_preview_path (chooser);
1384 }
1385
1386 /**
1387  * _gtk_file_chooser_add_shortcut_folder:
1388  * @chooser: a #GtkFileChooser
1389  * @path: path of the folder to add
1390  * @error: location to store error, or %NULL
1391  * 
1392  * Adds a folder to be displayed with the shortcut folders in a file chooser.
1393  * Internal function, see gtk_file_chooser_add_shortcut_folder().
1394  * 
1395  * Return value: %TRUE if the folder could be added successfully, %FALSE
1396  * otherwise.
1397  *
1398  * Since: 2.4
1399  **/
1400 gboolean
1401 _gtk_file_chooser_add_shortcut_folder (GtkFileChooser    *chooser,
1402                                        const GtkFilePath *path,
1403                                        GError           **error)
1404 {
1405   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1406   g_return_val_if_fail (path != NULL, FALSE);
1407
1408   return GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_shortcut_folder (chooser, path, error);
1409 }
1410
1411 /**
1412  * _gtk_file_chooser_remove_shortcut_folder:
1413  * @chooser: a #GtkFileChooser
1414  * @path: path of the folder to remove
1415  * @error: location to store error, or %NULL
1416  * 
1417  * Removes a folder from the shortcut folders in a file chooser.  Internal
1418  * function, see gtk_file_chooser_remove_shortcut_folder().
1419  * 
1420  * Return value: %TRUE if the folder could be removed successfully, %FALSE
1421  * otherwise.
1422  *
1423  * Since: 2.4
1424  **/
1425 gboolean
1426 _gtk_file_chooser_remove_shortcut_folder (GtkFileChooser    *chooser,
1427                                           const GtkFilePath *path,
1428                                           GError           **error)
1429 {
1430   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1431   g_return_val_if_fail (path != NULL, FALSE);
1432
1433   return GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_shortcut_folder (chooser, path, error);
1434 }
1435
1436 /**
1437  * gtk_file_chooser_get_preview_filename:
1438  * @chooser: a #GtkFileChooser
1439  * 
1440  * Gets the filename that should be previewed in a custom preview
1441  * widget. See gtk_file_chooser_set_preview_widget().
1442  * 
1443  * Return value: the filename to preview, or %NULL if no file
1444  *  is selected, or if the selected file cannot be represented
1445  *  as a local filename. Free with g_free()
1446  *
1447  * Since: 2.4
1448  **/
1449 char *
1450 gtk_file_chooser_get_preview_filename (GtkFileChooser *chooser)
1451 {
1452   GtkFileSystem *file_system;
1453   GtkFilePath *path;
1454   gchar *result = NULL;
1455   
1456   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1457
1458   file_system = _gtk_file_chooser_get_file_system (chooser);
1459   path = _gtk_file_chooser_get_preview_path (chooser);
1460   if (path)
1461     {
1462       result = gtk_file_system_path_to_filename (file_system, path);
1463       gtk_file_path_free (path);
1464     }
1465
1466   return result;
1467 }
1468
1469 /**
1470  * gtk_file_chooser_get_preview_uri:
1471  * @chooser: a #GtkFileChooser
1472  * 
1473  * Gets the URI that should be previewed in a custom preview
1474  * widget. See gtk_file_chooser_set_preview_widget().
1475  * 
1476  * Return value: the URI for the file to preview, or %NULL if no file is
1477  * selected. Free with g_free().
1478  *
1479  * Since: 2.4
1480  **/
1481 char *
1482 gtk_file_chooser_get_preview_uri (GtkFileChooser *chooser)
1483 {
1484   GtkFileSystem *file_system;
1485   GtkFilePath *path;
1486   gchar *result = NULL;
1487   
1488   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1489
1490   file_system = _gtk_file_chooser_get_file_system (chooser);
1491   path = _gtk_file_chooser_get_preview_path (chooser);
1492   if (path)
1493     {
1494       result = gtk_file_system_path_to_uri (file_system, path);
1495       gtk_file_path_free (path);
1496     }
1497
1498   return result;
1499 }
1500
1501 /**
1502  * gtk_file_chooser_set_extra_widget:
1503  * @chooser: a #GtkFileChooser
1504  * @extra_widget: widget for extra options
1505  * 
1506  * Sets an application-supplied widget to provide extra options to the user.
1507  *
1508  * Since: 2.4
1509  **/
1510 void
1511 gtk_file_chooser_set_extra_widget (GtkFileChooser *chooser,
1512                                    GtkWidget      *extra_widget)
1513 {
1514   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1515
1516   g_object_set (chooser, "extra-widget", extra_widget, NULL);
1517 }
1518
1519 /**
1520  * gtk_file_chooser_get_extra_widget:
1521  * @chooser: a #GtkFileChooser
1522  * 
1523  * Gets the current preview widget; see
1524  * gtk_file_chooser_set_extra_widget().
1525  * 
1526  * Return value: the current extra widget, or %NULL
1527  *
1528  * Since: 2.4
1529  **/
1530 GtkWidget *
1531 gtk_file_chooser_get_extra_widget (GtkFileChooser *chooser)
1532 {
1533   GtkWidget *extra_widget;
1534   
1535   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1536
1537   g_object_get (chooser, "extra-widget", &extra_widget, NULL);
1538   
1539   /* Horrid hack; g_object_get() refs returned objects but
1540    * that contradicts the memory management conventions
1541    * for accessors.
1542    */
1543   if (extra_widget)
1544     g_object_unref (extra_widget);
1545
1546   return extra_widget;
1547 }
1548
1549 /**
1550  * gtk_file_chooser_add_filter:
1551  * @chooser: a #GtkFileChooser
1552  * @filter: a #GtkFileFilter
1553  * 
1554  * Adds @filter to the list of filters that the user can select between.
1555  * When a filter is selected, only files that are passed by that
1556  * filter are displayed. 
1557  * 
1558  * Note that the @chooser takes ownership of the filter, so you have to 
1559  * ref and sink it if you want to keep a reference.
1560  *
1561  * Since: 2.4
1562  **/
1563 void
1564 gtk_file_chooser_add_filter (GtkFileChooser *chooser,
1565                              GtkFileFilter  *filter)
1566 {
1567   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1568
1569   GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_filter (chooser, filter);
1570 }
1571
1572 /**
1573  * gtk_file_chooser_remove_filter:
1574  * @chooser: a #GtkFileChooser
1575  * @filter: a #GtkFileFilter
1576  * 
1577  * Removes @filter from the list of filters that the user can select between.
1578  *
1579  * Since: 2.4
1580  **/
1581 void
1582 gtk_file_chooser_remove_filter (GtkFileChooser *chooser,
1583                                 GtkFileFilter  *filter)
1584 {
1585   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1586
1587   GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_filter (chooser, filter);
1588 }
1589
1590 /**
1591  * gtk_file_chooser_list_filters:
1592  * @chooser: a #GtkFileChooser
1593  * 
1594  * Lists the current set of user-selectable filters; see
1595  * gtk_file_chooser_add_filter(), gtk_file_chooser_remove_filter().
1596  * 
1597  * Return value: a #GSList containing the current set of
1598  *  user selectable filters. The contents of the list are
1599  *  owned by GTK+, but you must free the list itself with
1600  *  g_slist_free() when you are done with it.
1601  *
1602  * Since: 2.4
1603  **/
1604 GSList *
1605 gtk_file_chooser_list_filters  (GtkFileChooser *chooser)
1606 {
1607   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1608
1609   return GTK_FILE_CHOOSER_GET_IFACE (chooser)->list_filters (chooser);
1610 }
1611
1612 /**
1613  * gtk_file_chooser_set_filter:
1614  * @chooser: a #GtkFileChooser
1615  * @filter: a #GtkFileFilter
1616  * 
1617  * Sets the current filter; only the files that pass the
1618  * filter will be displayed. If the user-selectable list of filters
1619  * is non-empty, then the filter should be one of the filters
1620  * in that list. Setting the current filter when the list of
1621  * filters is empty is useful if you want to restrict the displayed
1622  * set of files without letting the user change it.
1623  *
1624  * Since: 2.4
1625  **/
1626 void
1627 gtk_file_chooser_set_filter (GtkFileChooser *chooser,
1628                              GtkFileFilter  *filter)
1629 {
1630   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1631   g_return_if_fail (GTK_IS_FILE_FILTER (filter));
1632
1633   g_object_set (chooser, "filter", filter, NULL);
1634 }
1635
1636 /**
1637  * gtk_file_chooser_get_filter:
1638  * @chooser: a #GtkFileChooser
1639  * 
1640  * Gets the current filter; see gtk_file_chooser_set_filter().
1641  * 
1642  * Return value: the current filter, or %NULL
1643  *
1644  * Since: 2.4
1645  **/
1646 GtkFileFilter *
1647 gtk_file_chooser_get_filter (GtkFileChooser *chooser)
1648 {
1649   GtkFileFilter *filter;
1650   
1651   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1652
1653   g_object_get (chooser, "filter", &filter, NULL);
1654   /* Horrid hack; g_object_get() refs returned objects but
1655    * that contradicts the memory management conventions
1656    * for accessors.
1657    */
1658   if (filter)
1659     g_object_unref (filter);
1660
1661   return filter;
1662 }
1663
1664 /**
1665  * gtk_file_chooser_add_shortcut_folder:
1666  * @chooser: a #GtkFileChooser
1667  * @folder: filename of the folder to add
1668  * @error: location to store error, or %NULL
1669  * 
1670  * Adds a folder to be displayed with the shortcut folders in a file chooser.
1671  * Note that shortcut folders do not get saved, as they are provided by the
1672  * application.  For example, you can use this to add a
1673  * "/usr/share/mydrawprogram/Clipart" folder to the volume list.
1674  * 
1675  * Return value: %TRUE if the folder could be added successfully, %FALSE
1676  * otherwise.  In the latter case, the @error will be set as appropriate.
1677  *
1678  * Since: 2.4
1679  **/
1680 gboolean
1681 gtk_file_chooser_add_shortcut_folder (GtkFileChooser    *chooser,
1682                                       const char        *folder,
1683                                       GError           **error)
1684 {
1685   GtkFilePath *path;
1686   gboolean result;
1687
1688   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1689   g_return_val_if_fail (folder != NULL, FALSE);
1690
1691   path = gtk_file_system_filename_to_path (_gtk_file_chooser_get_file_system (chooser), folder);
1692   if (!path)
1693     {
1694       g_set_error (error,
1695                    GTK_FILE_CHOOSER_ERROR,
1696                    GTK_FILE_CHOOSER_ERROR_BAD_FILENAME,
1697                    _("Invalid filename: %s"),
1698                    folder);
1699       return FALSE;
1700     }
1701
1702   result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_shortcut_folder (chooser, path, error);
1703
1704   gtk_file_path_free (path);
1705
1706   return result;
1707 }
1708
1709 /**
1710  * gtk_file_chooser_remove_shortcut_folder:
1711  * @chooser: a #GtkFileChooser
1712  * @folder: filename of the folder to remove
1713  * @error: location to store error, or %NULL
1714  * 
1715  * Removes a folder from a file chooser's list of shortcut folders.
1716  * 
1717  * Return value: %TRUE if the operation succeeds, %FALSE otherwise.  
1718  * In the latter case, the @error will be set as appropriate.
1719  *
1720  * See also: gtk_file_chooser_add_shortcut_folder()
1721  *
1722  * Since: 2.4
1723  **/
1724 gboolean
1725 gtk_file_chooser_remove_shortcut_folder (GtkFileChooser    *chooser,
1726                                          const char        *folder,
1727                                          GError           **error)
1728 {
1729   GtkFilePath *path;
1730   gboolean result;
1731
1732   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1733   g_return_val_if_fail (folder != NULL, FALSE);
1734
1735   path = gtk_file_system_filename_to_path (_gtk_file_chooser_get_file_system (chooser), folder);
1736   if (!path)
1737     {
1738       g_set_error (error,
1739                    GTK_FILE_CHOOSER_ERROR,
1740                    GTK_FILE_CHOOSER_ERROR_BAD_FILENAME,
1741                    _("Invalid filename: %s"),
1742                    folder);
1743       return FALSE;
1744     }
1745
1746   result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_shortcut_folder (chooser, path, error);
1747
1748   gtk_file_path_free (path);
1749
1750   return result;
1751 }
1752
1753 /**
1754  * gtk_file_chooser_list_shortcut_folders:
1755  * @chooser: a #GtkFileChooser
1756  * 
1757  * Queries the list of shortcut folders in the file chooser, as set by
1758  * gtk_file_chooser_add_shortcut_folder().
1759  * 
1760  * Return value: A list of folder filenames, or %NULL if there are no shortcut
1761  * folders.  Free the returned list with g_slist_free(), and the filenames with
1762  * g_free().
1763  *
1764  * Since: 2.4
1765  **/
1766 GSList *
1767 gtk_file_chooser_list_shortcut_folders (GtkFileChooser *chooser)
1768 {
1769   GSList *folders;
1770   GSList *result;
1771
1772   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1773
1774   folders = GTK_FILE_CHOOSER_GET_IFACE (chooser)->list_shortcut_folders (chooser);
1775
1776   result = file_paths_to_strings (_gtk_file_chooser_get_file_system (chooser),
1777                                   folders,
1778                                   gtk_file_system_path_to_filename);
1779   gtk_file_paths_free (folders);
1780   return result;
1781 }
1782
1783 /**
1784  * gtk_file_chooser_add_shortcut_folder_uri:
1785  * @chooser: a #GtkFileChooser
1786  * @uri: URI of the folder to add
1787  * @error: location to store error, or %NULL
1788  * 
1789  * Adds a folder URI to be displayed with the shortcut folders in a file
1790  * chooser.  Note that shortcut folders do not get saved, as they are provided
1791  * by the application.  For example, you can use this to add a
1792  * "file:///usr/share/mydrawprogram/Clipart" folder to the volume list.
1793  * 
1794  * Return value: %TRUE if the folder could be added successfully, %FALSE
1795  * otherwise.  In the latter case, the @error will be set as appropriate.
1796  *
1797  * Since: 2.4
1798  **/
1799 gboolean
1800 gtk_file_chooser_add_shortcut_folder_uri (GtkFileChooser    *chooser,
1801                                           const char        *uri,
1802                                           GError           **error)
1803 {
1804   GtkFilePath *path;
1805   gboolean result;
1806
1807   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1808   g_return_val_if_fail (uri != NULL, FALSE);
1809
1810   path = gtk_file_system_uri_to_path (_gtk_file_chooser_get_file_system (chooser), uri);
1811   if (!path)
1812     {
1813       g_set_error (error,
1814                    GTK_FILE_CHOOSER_ERROR,
1815                    GTK_FILE_CHOOSER_ERROR_BAD_FILENAME,
1816                    _("Invalid filename: %s"),
1817                    uri);
1818       return FALSE;
1819     }
1820
1821   result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_shortcut_folder (chooser, path, error);
1822
1823   gtk_file_path_free (path);
1824
1825   return result;
1826 }
1827
1828 /**
1829  * gtk_file_chooser_remove_shortcut_folder_uri:
1830  * @chooser: a #GtkFileChooser
1831  * @uri: URI of the folder to remove
1832  * @error: location to store error, or %NULL
1833  * 
1834  * Removes a folder URI from a file chooser's list of shortcut folders.
1835  * 
1836  * Return value: %TRUE if the operation succeeds, %FALSE otherwise.  
1837  * In the latter case, the @error will be set as appropriate.
1838  *
1839  * See also: gtk_file_chooser_add_shortcut_folder_uri()
1840  *
1841  * Since: 2.4
1842  **/
1843 gboolean
1844 gtk_file_chooser_remove_shortcut_folder_uri (GtkFileChooser    *chooser,
1845                                              const char        *uri,
1846                                              GError           **error)
1847 {
1848   GtkFilePath *path;
1849   gboolean result;
1850
1851   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1852   g_return_val_if_fail (uri != NULL, FALSE);
1853
1854   path = gtk_file_system_uri_to_path (_gtk_file_chooser_get_file_system (chooser), uri);
1855   if (!path)
1856     {
1857       g_set_error (error,
1858                    GTK_FILE_CHOOSER_ERROR,
1859                    GTK_FILE_CHOOSER_ERROR_BAD_FILENAME,
1860                    _("Invalid filename: %s"),
1861                    uri);
1862       return FALSE;
1863     }
1864
1865   result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_shortcut_folder (chooser, path, error);
1866
1867   gtk_file_path_free (path);
1868
1869   return result;
1870 }
1871
1872 /**
1873  * gtk_file_chooser_list_shortcut_folder_uris:
1874  * @chooser: a #GtkFileChooser
1875  * 
1876  * Queries the list of shortcut folders in the file chooser, as set by
1877  * gtk_file_chooser_add_shortcut_folder_uri().
1878  * 
1879  * Return value: A list of folder URIs, or %NULL if there are no shortcut
1880  * folders.  Free the returned list with g_slist_free(), and the URIs with
1881  * g_free().
1882  *
1883  * Since: 2.4
1884  **/
1885 GSList *
1886 gtk_file_chooser_list_shortcut_folder_uris (GtkFileChooser *chooser)
1887 {
1888   GSList *folders;
1889   GSList *result;
1890
1891   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1892
1893   folders = GTK_FILE_CHOOSER_GET_IFACE (chooser)->list_shortcut_folders (chooser);
1894
1895   result = file_paths_to_strings (_gtk_file_chooser_get_file_system (chooser),
1896                                   folders,
1897                                   gtk_file_system_path_to_uri);
1898   gtk_file_paths_free (folders);
1899   return result;
1900 }
1901
1902
1903 /**
1904  * gtk_file_chooser_set_show_hidden:
1905  * @chooser: a #GtkFileChooser
1906  * @show_hidden: %TRUE if hidden files and folders should be displayed.
1907  * 
1908  * Sets whether hidden files and folders are displayed in the file selector.  
1909  *
1910  * Since: 2.6
1911  **/
1912 void
1913 gtk_file_chooser_set_show_hidden (GtkFileChooser *chooser,
1914                                   gboolean        show_hidden)
1915 {
1916   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1917
1918   g_object_set (chooser, "show-hidden", show_hidden, NULL);
1919 }
1920
1921 /**
1922  * gtk_file_chooser_get_show_hidden:
1923  * @chooser: a #GtkFileChooser
1924  * 
1925  * Gets whether hidden files and folders are displayed in the file selector.   
1926  * See gtk_file_chooser_set_show_hidden().
1927  * 
1928  * Return value: %TRUE if hidden files and folders are displayed.
1929  *
1930  * Since: 2.6
1931  **/
1932 gboolean
1933 gtk_file_chooser_get_show_hidden (GtkFileChooser *chooser)
1934 {
1935   gboolean show_hidden;
1936   
1937   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1938
1939   g_object_get (chooser, "show-hidden", &show_hidden, NULL);
1940
1941   return show_hidden;
1942 }
1943
1944 /**
1945  * gtk_file_chooser_set_do_overwrite_confirmation:
1946  * @chooser: a #GtkFileChooser
1947  * @do_overwrite_confirmation: whether to confirm overwriting in save mode
1948  * 
1949  * Sets whether a file chooser in GTK_FILE_CHOOSER_ACTION_SAVE mode will present
1950  * a confirmation dialog if the user types a file name that already exists.  This
1951  * is %FALSE by default.
1952  *
1953  * Regardless of this setting, the @chooser will emit the "confirm-overwrite"
1954  * signal when appropriate.
1955  *
1956  * If all you need is the stock confirmation dialog, set this property to %TRUE.
1957  * You can override the way confirmation is done by actually handling the
1958  * "confirm-overwrite" signal; please refer to its documentation for the
1959  * details.
1960  *
1961  * Since: 2.8
1962  **/
1963 void
1964 gtk_file_chooser_set_do_overwrite_confirmation (GtkFileChooser *chooser,
1965                                                 gboolean        do_overwrite_confirmation)
1966 {
1967   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1968
1969   g_object_set (chooser, "do-overwrite-confirmation", do_overwrite_confirmation, NULL);
1970 }
1971
1972 /**
1973  * gtk_file_chooser_get_do_overwrite_confirmation:
1974  * @chooser: a #GtkFileChooser
1975  * 
1976  * Queries whether a file chooser is set to confirm for overwriting when the user
1977  * types a file name that already exists.
1978  * 
1979  * Return value: %TRUE if the file chooser will present a confirmation dialog;
1980  * %FALSE otherwise.
1981  *
1982  * Since: 2.8
1983  **/
1984 gboolean
1985 gtk_file_chooser_get_do_overwrite_confirmation (GtkFileChooser *chooser)
1986 {
1987   gboolean do_overwrite_confirmation;
1988
1989   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1990
1991   g_object_get (chooser, "do-overwrite-confirmation", &do_overwrite_confirmation, NULL);
1992
1993   return do_overwrite_confirmation;
1994 }
1995
1996 #ifdef G_OS_WIN32
1997
1998 /* DLL ABI stability backward compatibility versions */
1999
2000 #undef gtk_file_chooser_get_filename
2001
2002 gchar *
2003 gtk_file_chooser_get_filename (GtkFileChooser *chooser)
2004 {
2005   gchar *utf8_filename = gtk_file_chooser_get_filename_utf8 (chooser);
2006   gchar *retval = g_locale_from_utf8 (utf8_filename, -1, NULL, NULL, NULL);
2007
2008   g_free (utf8_filename);
2009
2010   return retval;
2011 }
2012
2013 #undef gtk_file_chooser_set_filename
2014
2015 gboolean
2016 gtk_file_chooser_set_filename (GtkFileChooser *chooser,
2017                                const gchar    *filename)
2018 {
2019   gchar *utf8_filename = g_locale_to_utf8 (filename, -1, NULL, NULL, NULL);
2020   gboolean retval = gtk_file_chooser_set_filename_utf8 (chooser, utf8_filename);
2021
2022   g_free (utf8_filename);
2023
2024   return retval;
2025 }
2026
2027 #undef gtk_file_chooser_select_filename
2028
2029 gboolean
2030 gtk_file_chooser_select_filename (GtkFileChooser *chooser,
2031                                   const gchar    *filename)
2032 {
2033   gchar *utf8_filename = g_locale_to_utf8 (filename, -1, NULL, NULL, NULL);
2034   gboolean retval = gtk_file_chooser_select_filename_utf8 (chooser, utf8_filename);
2035
2036   g_free (utf8_filename);
2037
2038   return retval;
2039 }
2040
2041 #undef gtk_file_chooser_unselect_filename
2042
2043 void
2044 gtk_file_chooser_unselect_filename (GtkFileChooser *chooser,
2045                                     const char     *filename)
2046 {
2047   gchar *utf8_filename = g_locale_to_utf8 (filename, -1, NULL, NULL, NULL);
2048
2049   gtk_file_chooser_unselect_filename_utf8 (chooser, utf8_filename);
2050   g_free (utf8_filename);
2051 }
2052
2053 #undef gtk_file_chooser_get_filenames
2054
2055 GSList *
2056 gtk_file_chooser_get_filenames (GtkFileChooser *chooser)
2057 {
2058   GSList *list = gtk_file_chooser_get_filenames_utf8 (chooser);
2059   GSList *rover = list;
2060   
2061   while (rover)
2062     {
2063       gchar *tem = (gchar *) rover->data;
2064       rover->data = g_locale_from_utf8 ((gchar *) rover->data, -1, NULL, NULL, NULL);
2065       g_free (tem);
2066       rover = rover->next;
2067     }
2068
2069   return list;
2070 }
2071
2072 #undef gtk_file_chooser_set_current_folder
2073
2074 gboolean
2075 gtk_file_chooser_set_current_folder (GtkFileChooser *chooser,
2076                                      const gchar    *filename)
2077 {
2078   gchar *utf8_filename = g_locale_to_utf8 (filename, -1, NULL, NULL, NULL);
2079   gboolean retval = gtk_file_chooser_set_current_folder_utf8 (chooser, utf8_filename);
2080
2081   g_free (utf8_filename);
2082
2083   return retval;
2084 }
2085
2086 #undef gtk_file_chooser_get_current_folder
2087
2088 gchar *
2089 gtk_file_chooser_get_current_folder (GtkFileChooser *chooser)
2090 {
2091   gchar *utf8_folder = gtk_file_chooser_get_current_folder_utf8 (chooser);
2092   gchar *retval = g_locale_from_utf8 (utf8_folder, -1, NULL, NULL, NULL);
2093
2094   g_free (utf8_folder);
2095
2096   return retval;
2097 }
2098
2099 #undef gtk_file_chooser_get_preview_filename
2100
2101 char *
2102 gtk_file_chooser_get_preview_filename (GtkFileChooser *chooser)
2103 {
2104   char *utf8_filename = gtk_file_chooser_get_preview_filename_utf8 (chooser);
2105   char *retval = g_locale_from_utf8 (utf8_filename, -1, NULL, NULL, NULL);
2106
2107   g_free (utf8_filename);
2108
2109   return retval;
2110 }
2111
2112 #undef gtk_file_chooser_add_shortcut_folder
2113
2114 gboolean
2115 gtk_file_chooser_add_shortcut_folder (GtkFileChooser    *chooser,
2116                                       const char        *folder,
2117                                       GError           **error)
2118 {
2119   char *utf8_folder = g_locale_to_utf8 (folder, -1, NULL, NULL, NULL);
2120   gboolean retval =
2121     gtk_file_chooser_add_shortcut_folder_utf8 (chooser, utf8_folder, error);
2122
2123   g_free (utf8_folder);
2124
2125   return retval;
2126 }
2127
2128 #undef gtk_file_chooser_remove_shortcut_folder
2129
2130 gboolean
2131 gtk_file_chooser_remove_shortcut_folder (GtkFileChooser    *chooser,
2132                                          const char        *folder,
2133                                          GError           **error)
2134 {
2135   char *utf8_folder = g_locale_to_utf8 (folder, -1, NULL, NULL, NULL);
2136   gboolean retval =
2137     gtk_file_chooser_remove_shortcut_folder_utf8 (chooser, utf8_folder, error);
2138
2139   g_free (utf8_folder);
2140
2141   return retval;
2142 }
2143
2144 #undef gtk_file_chooser_list_shortcut_folders
2145
2146 GSList *
2147 gtk_file_chooser_list_shortcut_folders (GtkFileChooser *chooser)
2148 {
2149   GSList *list = gtk_file_chooser_list_shortcut_folders_utf8 (chooser);
2150   GSList *rover = list;
2151   
2152   while (rover)
2153     {
2154       gchar *tem = (gchar *) rover->data;
2155       rover->data = g_locale_from_utf8 ((gchar *) rover->data, -1, NULL, NULL, NULL);
2156       g_free (tem);
2157       rover = rover->next;
2158     }
2159
2160   return list;
2161 }
2162
2163 #endif
2164
2165 #define __GTK_FILE_CHOOSER_C__
2166 #include "gtkaliasdef.c"