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