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